8

I format my imac and delete all files on HD. However, when i install angular cli 7, terminal console show this error log.

Enviroment

macOS: Mojave 10.14.2 node: v10.15 npm: 6.4.1


Console error

miguels-imac:~ makito$ sudo npm install -g @angular/cli
/usr/local/bin/ng -> /usr/local/lib/node_modules/@angular/cli/bin/ng

> fsevents@1.2.7 install 
/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents
> node install

node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for fsevents@1.2.7 
and node@10.15.0 (node-v64 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/lib'
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/build'
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/Cellar/node@10/10.15.0/bin/node" "/usr/local/Cellar/node@10/10.15.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" "--module_name=fse" "--module_path=/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64" "--napi_version=3" "--node_abi_napi=napi"
gyp ERR! cwd /usr/local/lib/node_modules/@angular/cli/node_modules/fsevents
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/Cellar/node@10/10.15.0/bin/node /usr/local/Cellar/node@10/10.15.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64 --napi_version=3 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:962:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
node-pre-gyp ERR! System Darwin 18.2.0
node-pre-gyp ERR! command "/usr/local/Cellar/node@10/10.15.0/bin/node" "/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/@angular/cli/node_modules/fsevents
node-pre-gyp ERR! node -v v10.15.0
node-pre-gyp ERR! node-pre-gyp -v v0.10.3
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/Cellar/node@10/10.15.0/bin/node /usr/local/Cellar/node@10/10.15.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/@angular/cli/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64 --napi_version=3 --node_abi_napi=napi' (1)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/@angular/cli/node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 install: `node install`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

+ @angular/cli@7.2.3
added 294 packages from 178 contributors in 20.637s

if i show global dependencies, i have @angular/cli... so, why this error ?, what im doing wrong ?.

searching on stackOverflow, i decide install node-pre-gyp, and install xCode. but, nothing change.

makitocode
  • 938
  • 1
  • 16
  • 40

3 Answers3

16

Well I did this and it worked for me.

  1. rm -rf /usr/local/lib/node_modules
  2. brew uninstall node
  3. brew install node --without-npm
  4. echo prefix=~/.npm-packages >> ~/.npmrc
  5. curl -L https://www.npmjs.com/install.sh | sh
  6. add the following line to your ~/.bash_profile (export PATH="$HOME/.npm-packages/bin:$PATH")

  7. Unistall your current @angular/cli (sudo npm uninstall -g @angular/cli)

  8. npm cache clean --force / npm cache verify
  9. xcode-select --install
  10. npm install -g node-gyp
  11. npm install -g @angular/cli (without sudo).

Let me know if it works

Code Mickey
  • 947
  • 6
  • 9
  • 1
    This guy. :) I didn't use brew, but I did clean up (reinstall) node and npm, then start from step 7 here. No more errors from fsevents. Thanks! – WonderGrub Jan 26 '19 at 20:10
  • I followed starting step 4 (did not reinstall node), and it worked! I wonder if it had something to do with changing to use the user's $HOME/.npm-packages/bin instead of root – Leonya Apr 26 '19 at 14:30
  • I had some errors on 3, 8, and 9, but this worked for me when I had trouble installing a different module but was getting the same error--thank you! Nothing else I tried worked! – lizziepika Feb 19 '20 at 20:58
3

You're not doing anything wrong, there is some error related to (probably) fsevents, both official package from node.js (lts and current) and homebrew installs have this issue.

Follow answers on this thread: How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)

[basically you need to remove node, npm, ng files and folders manually]

and install nvm and then node with nvm.

eliwuu
  • 46
  • 1
  • 3
  • NOTE: This response helped me much more than the other. I think the key is to completely eliminate any traces of nodejs and npm. It does not matter which method you have used (brew, nvm, package). I personally used "nvm" because it makes it easier for me to manage multiple versions of node and it is very easy to use, BUT before installing `@ angular / cli`, they must install `node-gyp` and must have Xcode installed. I mean, 1.Unistall node (completely), 2. install nvm, 3.install node version, 4. install `node-gyp` and 5. Install `@angular/cli` – makitocode Jan 28 '19 at 21:23
  • 1
    This worked for me: uninstall node completely, install nvm, nvm install --lts, npm install -g node-gyp, npm install -g @angular/cli (all commands without sudo), thanks @Makito for the comment. – Kumait Apr 21 '19 at 01:27
0

I tried the above fixes and yet, got the same issue. I think despite the warnings and errors, the CLI should be installed correctly.

I ran ng v and could see the new version installed.

A similar issue has been logged here https://github.com/aws-amplify/amplify-cli/issues/783

Kaustubh - KAY
  • 119
  • 1
  • 3