【问题标题】:Unable to run "npm start" shows error. how to resolve?无法运行“npm start”显示错误。如何解决?
【发布时间】:2017-07-03 20:47:31
【问题描述】:

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

showing error

包.json

Packages.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' ]​​i>
  • 2 信息使用 npm@4.2.0
  • 3 使用 node@v6.9.3 的信息
  • 4 个详细的运行脚本 ['prestart', 'start', 'poststart']
  • 5 信息生命周期 hello-world@0.1.0~prestart: hello-world@0.1.0
  • 6 愚蠢的生命周期 hello-world@0.1.0~prestart:没有预启动脚本,继续
  • 7 信息生命周期 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' ]​​i>
  • 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 个详细堆栈
  • mayberClose 的 14 个详细堆栈 (internal/child_process.js:877:16)
  • Process.ChildProcess._handle.onexit 的 14 个详细堆栈 (internal/child_process.js:226:5)
  • 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" "start"李>
  • 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 owner ls hello-world
  • 24 错误上面可能有额外的日志输出。
  • 25 详细退出 [4294967295, true]

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

【问题讨论】:

  • 你确定你安装了webpack-dev-server

标签: node.js npm


【解决方案1】:

尝试输入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'
            }
        ]
    }

};

【讨论】:

  • start有什么问题吗:webpack-dev-server --hot
  • 附加了我的 webpack.config.js
  • 检查 node_modules 文件夹是否已创建在与您运行 npm install 相同的目录中
  • 是的,在同一个目录下。
  • 您的 webpack 配置看起来与 webpack 主页上的基本示例以及我的不同。我会更新我的答案
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 2020-07-19
    • 2021-12-20
    • 2021-10-10
    • 2021-08-20
    • 2021-04-19
    • 2020-10-24
    • 2020-11-26
    • 1970-01-01
    • 2021-10-03
    相关资源
    最近更新 更多