2017-03-06 80 views
1

我有开始NPM问题(ReactJS)错误NPM开始ReactJS

当我运行终端npm start

这是显示错误:

ERROR in multi (webpack)-dev-server/client? http://localhost:8080 webpack/hot/dev-server /index.js Module not found: Error: Can't resolve '/index.js' in '/home/truc/TrucTran/dev/workspace/reactapp' @ multi (webpack)-dev-server/client? http://localhost:8080 webpack/hot/dev-server /index.js webpack: Failed to compile.

内容文件的package.json:

{ 
    "name": "reactapp", 
    "version": "1.0.0", 
    "description": "", 
    "main": "index.js", 
    "scripts": { 
    "start": "webpack-dev-server --hot" 
    }, 
    "author": "", 
    "license": "ISC", 
    "dependencies": { 
    "react": "^15.4.2", 
    "react-dom": "^15.4.2" 
    } 
} 

个内容文件webpack.package.js:

var config = { 
    entry: '/index.js', 

    output: { 
     path:'/home/truc/TrucTran/dev/workspace/reactapp/', 
     filename: 'index.js', 
    }, 

    devServer: { 
     inline: true, 
     port: 8080 
    }, 

    module: { 
     loaders: [ 
     { 
      test: /\.jsx?$/, 
      exclude: /node_modules/, 
      loader: 'babel', 
      query: { 
       presets: ['es2015', 'react'] 
      } 
     } 
     ] 
    } 
} 

module.exports = config; 

请帮我这个问题!

感谢

回答

0

随着错误消息状态,无法找到您index.js项文件。创建您的index.js文件并重新运行npm。

+0

文件index.js已经在我的目录中 –

+0

嗯,这就是我可以告诉你的全部内容,因为这实际上是错误说的,我没有足够的信息来真正跳到其他结论。我建议再次检查你的'index'文件所在的位置,或者再次检查你的配置。 – stinodes

+0

非常感谢stinodes :)我会审查整个项目 –