Angular-cli: Angular CLI postinstall script fails (with global flag), due to absence of ng-update-message.js

Created on 8 May 2018  路  9Comments  路  Source: angular/angular-cli

Versions

Node: v8.11.0
NPM: 5.6.0
OS: Linux Fedora 28

Repro steps

sudo npm install -g @angular/cli

Observed behavior

/usr/bin/ng -> /usr/lib/node_modules/@angular/cli/bin/ng

> @angular/[email protected] postinstall /usr/lib/node_modules/@angular/cli
> node ./bin/ng-update-message.js

module.js:549
    throw err;
    ^

Error: Cannot find module '/usr/lib/node_modules/@angular/cli/bin/ng-update-message.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/@angular/cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @angular/[email protected] postinstall: `node ./bin/ng-update-message.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @angular/[email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-05-08T12_16_40_014Z-debug.log

Desired behavior

The file ng-update-message.js is found, allowing NPM to install the Angular CLI globally

Mention any other details that might be useful (optional)

The install is successful if installed locally, by running...

cd ~/Desktop
npm install @angular/cli

In this case, ng-update-message.js is present under node_modules/@angular/cli/bin/

high broken bufix

Most helpful comment

I had the same error, and this is the solution worked for me:

sudo npm install -g @angular/cli --unsafe-perm=true --allow-root

I found it here

All 9 comments

I am working on a new machine and have just tried a global install of angular-cli - the first step in the tour of heroes tutorial. Same result as descibed here.

I have also tried without the -g flag. That doesn't work either.

Console (as admin)

C:\WINDOWS\system32>npm install -g @angular/cli
npm WARN engine @angular/[email protected]: wanted: {"node":">= 8.9.0","npm":">= 5.5.1"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine @schematics/[email protected]: wanted: {"node":">= 8.9.0","npm":">= 5.5.1"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine @angular-devkit/[email protected]: wanted: {"node":">= 8.9.0","npm":">= 5.5.1"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine @angular-devkit/[email protected]: wanted: {"node":">= 8.9.0","npm":">= 5.5.1"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine @schematics/[email protected]: wanted: {"node":">= 8.9.0","npm":">= 5.5.1"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine @angular-devkit/[email protected]: wanted: {"node":">= 8.9.0","npm":">= 5.5.1"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine [email protected]: wanted: {"node":">= 4"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN optional dep failed, continuing [email protected]
npm WARN engine [email protected]: wanted: {"node":">=4.5.0"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine [email protected]: wanted: {"node":">=4.2.0"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine [email protected]: wanted: {"node":">=4.0.0"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine [email protected]: wanted: {"node":">=4.0.0"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine [email protected]: wanted: {"node":">=4.0.0"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine [email protected]: wanted: {"node":">=4.0.0"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine [email protected]: wanted: {"node":">=4.0.0"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine [email protected]: wanted: {"node":">= 4.5.0"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine [email protected]: wanted: {"node":">= 4.5.0"} (current: {"node":"0.12.2","npm":"2.7.4"})
npm WARN engine [email protected]: wanted: {"node":">=6"} (current: {"node":"0.12.2","npm":"2.7.4"})
C:\Users\myusername\AppData\Roaming\npm\ng -> C:\Users\myusername\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng

@angular/[email protected] postinstall C:\Users\myusername\AppData\Roaming\npm\node_modules\@angular\cli
node ./bin/ng-update-message.js

C:\Users\myusername\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng-update-message.js:7
const fs = require('fs');
^^^^^
SyntaxError: Use of const in strict mode.
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\Program Files (x86)\nodejs\\node.exe" "C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js" "install" "-g" "@angular/cli"
npm ERR! node v0.12.2
npm ERR! npm v2.7.4
npm ERR! code ELIFECYCLE

npm ERR! @angular/[email protected] postinstall: node ./bin/ng-update-message.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @angular/[email protected] postinstall script 'node ./bin/ng-update-message.js'.
npm ERR! This is most likely a problem with the @angular/cli package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node ./bin/ng-update-message.js
npm ERR! You can get their info via:
npm ERR! npm owner ls @angular/cli
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! C:\WINDOWS\system32\npm-debug.log

I have just found this could be to do with the version of NodeJS or NPM. I've just got the latest installer from the NodeJs website and everything seems to have gone through ok.

I tried locally with Node 8.10, 9.11 and 10.1 and it works fine (could not reproduce). I'm going to say it's a Node fluke (there are always many in the first minors) and close this. If it still happens to you please open a new issue. Thanks!

I had the same error, and this is the solution worked for me:

sudo npm install -g @angular/cli --unsafe-perm=true --allow-root

I found it here

Hello Everyone,

Please help me out form this. i'm also getting this same problem.

@angular/[email protected] postinstall C:\Users\Apphub\AppData\Roaming\npm\node_modules\@angular\cli
node ./bin/ng-update-message.js

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\@angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! file bash
npm ERR! path bash
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn bash
npm ERR! @angular/[email protected] postinstall: node ./bin/ng-update-message.js
npm ERR! spawn bash ENOENT
npm ERR!
npm ERR! Failed at the @angular/[email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm -v 6.1.0
node 10.6.0

@Jikaworld You don't need --allow-root.
This command suffices: sudo npm install -g @angular/cli --unsafe-perm=true

Thanks @Jikaworld this solved a lot of problems for our docker build!

its my angular-cli version problem

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings