2016-05-02 33 views
1

鉴于此行index.jsx:模组分辨率没有扩展

import ExampleTable from 'table'; 

我越来越:

Module not found: Error: Cannot resolve module 'table' in global-path-to/application/public/scripts @ ./application/public/scripts/index.jsx 19:13-29

但table.jsx住该文件夹中,我已经尝试定义在webpack.config.js文件扩展名:

{ 
entry:SOURCE_DIRECTORY + '/index.jsx', 

output: 
{ 
    path:SCRIPT_DIRECTORY, 
    filename:'bundle.js' 
}, 

resolve: 
{ 
    extensions:['', '.js', '.jsx'] 
},  

module: 
{ 
    loaders: 
    [ 
     { 
      // Regular expression to find both .js and .jsx files. 
      test:/\.jsx?$/, 
      include:SCRIPT_DIRECTORY, 
      loader: 'babel' 
     } 
    ] 
} 
}; 

$ npm ls --depth 0 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
└── [email protected] 

回答

2

我想你只需要使用相对路径./table,否则它会尝试在node_modules中查找table包。

如果你有更复杂的路径,你也可以设置路径解析器中的WebPack配置:http://webpack.github.io/docs/configuration.html#resolve-root

+0

没错。这样可行。我以为我尝试了这种排列组合...... – Kenny