在安装反应时,npm开始不工作

时间:2017-02-07 10:59:04

标签: node.js reactjs webpack-dev-server

请参阅以下文件以供参考。在为react demo项目创建设置时,我无法启动npm start命令。

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

Webpack.config.js

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

   output: {
      path:'./',
      filename: 'index.js',
   },

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

   module: {
      loaders: [
         {
            test: /\.jsx?$/,
            exclude: /node_modules/,
            loader: 'babel',

            query: {
               presets: ['es2015', 'react']
            }
         }
      ]
   }
}

module.exports = config;

当我运行npm.start时,请找到以下日志

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using npm@2.15.1
3 info using node@v4.4.4
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info prestart package.json@1.0.0
6 info start package.json@1.0.0
7 verbose unsafe-perm in lifecycle true
8 info package.json@1.0.0 Failed to exec start script
9 verbose stack Error: package.json@1.0.0 start: `webpack-dev-server --hot`
9 verbose stack Exit status 1
9 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:217:16)
9 verbose stack     at emitTwo (events.js:87:13)
9 verbose stack     at EventEmitter.emit (events.js:172:7)
9 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:24:14)
9 verbose stack     at emitTwo (events.js:87:13)
9 verbose stack     at ChildProcess.emit (events.js:172:7)
9 verbose stack     at maybeClose (internal/child_process.js:827:16)
9 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
10 verbose pkgid package.json@1.0.0
11 verbose cwd C:\Users\abhishek_pal02\Desktop\reactApp
12 error Windows_NT 6.3.9600
13 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
14 error node v4.4.4
15 error npm  v2.15.1
16 error code ELIFECYCLE
17 error package.json@1.0.0 start: `webpack-dev-server --hot`
17 error Exit status 1
18 error Failed at the package.json@1.0.0 start script 'webpack-dev-server --hot'.
18 error This is most likely a problem with the package.json package,
18 error not with npm itself.
18 error Tell the author that this fails on your system:
18 error     webpack-dev-server --hot
18 error You can get information on how to open an issue for this project with:
18 error     npm bugs package.json
18 error Or if that isn't available, you can get their info via:
18 error
18 error     npm owner ls package.json
18 error There is likely additional logging output above.
19 verbose exit [ 1, true ]

请帮助解决此错误。提前谢谢。

-Abhishek

0 个答案:

没有答案