繁体   English   中英

无法运行“npm start”显示错误。 如何解决?

[英]Unable to run "npm start" shows error. how to resolve?

在 Windows 10 中运行注释“npm start”时出错。

显示错误

包.json

包.json

Log
  • 0 信息如果它以 ok 结尾,它就起作用了
  • 1个详细的cli ['C:\ Program Files \ nodejs \ node.exe',
  • 1 详细的 cli 'C:\Users\vkarutha\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js',
  • 1 详细的 cli 'start' ]
  • 2 使用 npm@4.2.0 的信息
  • 3 使用 node@v6.9.3 的信息
  • 4个详细的运行脚本['prestart','start','poststart']
  • 5 info 生命周期 hello-world@0.1.0~prestart: hello-world@0.1.0
  • 6 傻生命周期 hello-world@0.1.0~prestart: 没有预启动脚本,继续
  • 7 info 生命周期 hello-world@0.1.0~start: hello-world@0.1.0
  • 8 详细生命周期 hello-world@0.1.0~start: unsafe-perm in lifecycle true
  • 9 详细生命周期 hello-world@0.1.0~start: PATH: C:\Users\vkarutha\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin;C:\Users\vkarutha\Documents\React \hello-world\node_modules.bin;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\ v1.0\;C:\Program Files (x86)\WebEx\Productivity Tools;C:\Program Files (x86)\Cisco\OSD-ShellApplications;C:\Program Files\Java\jdk1.8.0_101\bin;C :\Cisco\software\apache-maven-3.3.9\bin;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Program Files\TortoiseSVN\bin;C:\Program Files \nodejs\bin;C:\Program Files (x86)\Sennheiser\SoftphoneSDK\;C:\Program Files (x86)\ssh 通信安全\ssh Secure Shell;C:\Users\vkarutha\AppData\Roaming\npm;C :\Program Files (x86)\Microsoft VS Code\bin;C:\Program Files\nodejs\bin
  • 10 详细生命周期 hello-world@0.1.0~start: CWD: C:\Users\vkarutha\Documents\React\hello-world
  • 11 愚蠢的生命周期 hello-world@0.1.0~start: Args: [ '/d /s /c', 'webpack-dev-server --hot' ]
  • 12 傻生命周期 hello-world@0.1.0~start: 返回: 代码: 4294967295 信号: null
  • 13 info 生命周期 hello-world@0.1.0~start: 执行启动脚本失败
  • 14 详细堆栈错误:hello-world@0.1.0 开始: webpack-dev-server --hot
  • 14 详细堆栈退出状态 4294967295
  • EventEmitter 的 14 个详细堆栈。 (C:\Users\vkarutha\AppData\Roaming\npm\node_modules\npm\lib\utils\lifecycle.js:279:16)
  • 在 emitTwo (events.js:106:13) 的 14 个详细堆栈
  • EventEmitter.emit (events.js:191:7) 的 14 个详细堆栈
  • ChildProcess 的 14 个详细堆栈。 (C:\Users\vkarutha\AppData\Roaming\npm\node_modules\npm\lib\utils\spawn.js:40:14)
  • 在 emitTwo (events.js:106:13) 的 14 个详细堆栈
  • ChildProcess.emit (events.js:191:7) 的 14 个详细堆栈
  • MaybeClose 的 14 个详细堆栈(内部/child_process.js:877:16)
  • Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) 的 14 个详细堆栈
  • 15 详细 pkgid hello-world@0.1.0
  • 16 详细 cwd C:\Users\vkarutha\Documents\React\hello-world
  • 17 错误 Windows_NT 10.0.10586
  • 18 错误 argv "C:\Program Files\nodejs\node.exe" "C:\Users\vkarutha\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "开始"
  • 19 错误节点 v6.9.3
  • 20 错误 npm v4.2.0
  • 21 错误代码 ELIFECYCLE
  • 22 错误 errno 4294967295
  • 23 错误 hello-world@0.1.0 开始: webpack-dev-server --hot
  • 23 错误退出状态 4294967295
  • 24 错误在 hello-world@0.1.0 启动脚本“webpack-dev-server --hot”处失败。
  • 24 错误确保您安装了最新版本的 node.js 和 npm。
  • 24 错误 如果你这样做了,这很可能是 hello-world 包的问题,
  • 24 错误与 npm 本身无关。
  • 24 错误告诉作者这在你的系统上失败了:
  • 24 错误 webpack-dev-server --hot
  • 24 错误您可以通过以下方式获取有关如何为此项目打开问题的信息:
  • 24 错误 npm 错误 hello-world
  • 24 错误 或者如果这不可用,您可以通过以下方式获取他们的信息:
  • 24 错误 npm 所有者 ls hello-world
  • 24 错误 上面可能有额外的日志输出。
  • 25 详细退出 [4294967295,真]

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']
            }
         }
      ]
   }
}

尝试输入npm run start alt npm r start

导航到 package.json 所在的同一文件夹,键入npm install以获取所有依赖项。 输入npm run start

你有webpack.config.js吗?

可能是格式错误的 webpack 配置:这是我的外观,(替换为你的东西):

var path = require('path');

module.exports = {
    context: path.resolve('src/main'),
    entry: {
        myapp: './dependencies.js',
    },
    output: {
        path: path.resolve('build/dev'),
        filename: '[name].js'
    },
    module: {
        loaders: [
            {
                test: /.(png|jpg|jpeg|gif|svg|woff|woff2|eot|ttf)(.*)$/,
                loader: 'url-loader?limit=100000'
            },
            {
                test: /\.css$/,
                loader: 'style-loader!css-loader'
            }
        ]
    }

};

您的 webpack.config.js 文件有问题。 您需要像这样导出配置对象-

module.exports = {
   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']
            }
         }
      ]
   }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM