【问题标题】:Failed at the myproject@1.0.0 build script 'webpack'在 myproject@1.0.0 构建脚本“webpack”中失败
【发布时间】:2017-02-08 13:54:33
【问题描述】:

我使用universal-starter 作为主干。

当我运行npm start 时,我得到了错误:

npm ERR! Darwin 15.6.0
npm ERR! argv "/Users/hongbo-miao/.nvm/versions/node/v6.3.1/bin/node" "/Users/hongbo-miao/.nvm/versions/node/v6.3.1/bin/npm" "run" "build"
npm ERR! node v6.3.1
npm ERR! npm  v3.10.5
npm ERR! code ELIFECYCLE
npm ERR! myproject@1.0.0 build: `webpack`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the myproject@1.0.0 build script 'webpack'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the myproject package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     webpack
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs myproject
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls myproject
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/hongbo-miao/projects/myproject/npm-debug.log

npm ERR! Darwin 15.6.0
npm ERR! argv "/Users/hongbo-miao/.nvm/versions/node/v6.3.1/bin/node" "/Users/hongbo-miao/.nvm/versions/node/v6.3.1/bin/npm" "start"
npm ERR! node v6.3.1
npm ERR! npm  v3.10.5
npm ERR! code ELIFECYCLE
npm ERR! myproject@1.0.0 prestart: `npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myproject@1.0.0 prestart script 'npm run build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the myproject package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs myproject
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls myproject
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/hongbo-miao/projects/myproject/npm-debug.log

我尝试了here提到的walkaround方式,让webpack回到2.1.0-beta.22版本

npm uninstall webpack --save-dev
npm install webpack@2.1.0-beta.22 --save-dev

但是,我仍然遇到了这个问题。

还有其他可能导致此问题的原因吗?谢谢

【问题讨论】:

  • 可能是你的 webpack 也升级了 23.beta 请检查 webpack 版本
  • @CodeBuster 我试过npm uninstall webpack --save-devnpm install webpack@2.1.0-beta.22 --save-dev。甚至是全球的npm install -g webpack@2.1.0-beta.22,但仍然是同样的问题......
  • 我遇到了类似的问题,那是因为 webpack 版本,我猜这个错误是因为版本问题(可能是一些包或 npm)。

标签: angular webpack angular2-universal


【解决方案1】:

对于大多数人来说,问题可能是因为您更新到最新的webpack@2.1.0-beta.23(有重大更改)而您尚未更新 webpack.config.ts

所以你可以这样做

npm uninstall webpack --save-dev
npm install webpack@2.1.0-beta.22 --save-dev

但是,我的错误是我改变了

styles: [
  require('./app.component.scss')
],

styleUrls: ['./app.component.scss'],

但是我没有正确设置 webpack,所以当我改回来时,它现在又可以工作了。

所以我想只要 webpack.config.ts 中有错误,就会发生这个错误。它只是没有说清楚错误在哪里。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-06-07
    • 2018-06-19
    • 1970-01-01
    • 1970-01-01
    • 2019-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多