Search code examples
angularwebpackangular2-universal

Failed at the [email protected] build script 'webpack'


I am using universal-starter as backbone.

When I run npm start, I got the error:

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! [email protected] build: `webpack`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] 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! [email protected] prestart: `npm run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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

I tried the walkaround way mentioned here, which let webpack back to version 2.1.0-beta.22

npm uninstall webpack --save-dev
npm install [email protected] --save-dev

However, I still got this issue.

Is there anything else that may cause this issue? Thanks


Solution

  • For most people, the problem may be because you updated to latest [email protected](has breaking change) while you haven't updated webpack.config.ts yet.

    So you can do

    npm uninstall webpack --save-dev
    npm install [email protected] --save-dev
    

    However, my mistake is that I change from

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

    to

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

    But I didn't set up webpack correctly, so when I change back, it works again now.

    So I guess this error will happen whenever there is a mistake in webpack.config.ts. It just does not say clear where is the mistake.