Amplify-cli: Error on install of CLI: root has no permissions to node_modules/fsevents

Created on 28 Jan 2019  路  7Comments  路  Source: aws-amplify/amplify-cli

Describe the bug
Trying install the latest version fo the CLI on Mac

To Reproduce
Steps to reproduce the behavior:

  1. Launch mac terminal
  2. sudo npm install -g @aws-amplify/cli
  3. See error

Expected behavior
Install the latest version 0.1.44

Screenshots
(attached)

Desktop (please complete the following information):

  • OS: Mac
  • Browser: Nope
  • Version: 10.13.6
    Smartphone (please complete the following information):
    n/a
    Additional context
    Although, the install appears to fail installation, the $ amplify init command DOES work. Not sure if completely installed or not.

[Results]
`sudo npm install -g @aws-amplify/cli
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
/usr/local/bin/amplify -> /usr/local/lib/node_modules/@aws-amplify/cli/bin/amplify

[email protected] install /usr/local/lib/node_modules/@aws-amplify/cli/node_modules/fsevents
node install

node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v57 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/@aws-amplify/cli/node_modules/fsevents/lib'
gyp WARN EACCES user "root" does not have permission to access the dev dir "/Users/denhills/.node-gyp/8.12.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/.node-gyp'
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" "--module_name=fse" "--module_path=/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64" "--napi_version=3" "--node_abi_napi=napi"
gyp ERR! cwd /usr/local/lib/node_modules/@aws-amplify/cli/node_modules/fsevents
gyp ERR! node -v v8.12.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/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64 --napi_version=3 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack at ChildProcess. (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:126:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:214:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:915:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
node-pre-gyp ERR! System Darwin 17.7.0
node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/@aws-amplify/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/@aws-amplify/cli/node_modules/fsevents
node-pre-gyp ERR! node -v v8.12.0
node-pre-gyp ERR! node-pre-gyp -v v0.10.3
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64 --napi_version=3 --node_abi_napi=napi' (1)
npm WARN [email protected] requires a peer of graphql@^0.11.0 || ^0.12.0 || ^0.13.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/@aws-amplify/cli/node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: node install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

  • @aws-amplify/[email protected]
    added 1879 packages from 1301 contributors in 37.612s
    螢 ~ git:(master) 鈻禶
bug

Most helpful comment

same issue,+1

All 7 comments

The CLI will install correctly and is not a blocker, but it will throw those warnings and show an error stack for fsevents installation which is a dev dependency and shouldn't affect the CLI workflows.
We're looking into how we can mitigate these warnings and the error stack.

same issue,+1

I had this issue when my node was installed using Homebrew on my mac (and hence the need to use sudo for npm install -g).

I no longer had this error after I switched to nvm.

Approximate procedure:

  • note the global npm installs using 'npm list -g --depth=0'
  • uninstall all the globally installed packages, for example, npm remove -g <package> (or probably could have just nuked the /usr/local/lib/node_modules directory)
  • uninstall node usingbrew uninstall node
  • install nvm (for example, curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash)
  • for some reason, I had to copy the nvm content from ~/.bashrc into ~/.bash_profile to get nvm working. First try next step without doing this.
  • install node via nvm (for example, nvm install --lts)
  • and just for fun, upgrade npm using npm install -g npm (note sudo not required)
  • reinstall all the global installs that you noted (for example, npm install -g @aws-amplify/cli)

note: sudo no longer required for global npm installs.

Hope this helps.

FYI. I hit a similar error on another package (not amplify-cli), which required switch from node 10 to node 8. Seems any library that uses fsevents needs to have a specific matching version of node depending on the fsevents version.

I also saw npm install -D fsevents@latest on another thread which helped some folks out.

THANK YOU @leantide !
I've spent days trying to get @aws-amplify/cli installed the past few days, to no avail ... until I tried your solution.

As @leantide mentioned above these warnings are tied to a specific version of node + the fsevents pacakge. This in no way affects the installation and usage of the CLI.

The procedure of @leantide worked for me. Basically getting rid of node completely through brew but also removing it from /usr/local/bin/node and /usr/local/bin/node_modules and THEN SOLELY relying on nvm installed through curl as leantide details worked

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adriatikgashi picture adriatikgashi  路  3Comments

ReidWeb picture ReidWeb  路  3Comments

rehos picture rehos  路  3Comments

darrentarrant picture darrentarrant  路  3Comments

amlcodes picture amlcodes  路  3Comments