Q: AWS-Amplify-cli fails to install on Mac Trying to install AWS-Amplify-CLI and followed this
When I run npm install -g @aws-amplify/cli or sudo npm install -g @aws-amplify/cli I get the following errors

node-pre-gyp WARN Using request for node-pre-gyp https download
  node-pre-gyp WARN Pre-built binaries not installable for fsevents@1.2.7 and node@11.8.0 (node-v67 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/node/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/lib'
  gyp ERR! configure error
  gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/node/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/build'
  gyp ERR! System Darwin 18.2.0
  gyp ERR! command "/usr/local/lib/node_modules/node/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/node/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node" "--module_name=fse" "--module_path=/usr/local/lib/node_modules/node/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64" "--napi_version=4" "--node_abi_napi=napi"
  gyp ERR! cwd /usr/local/lib/node_modules/node/lib/node_modules/@aws-amplify/cli/node_modules/fsevents
  gyp ERR! node -v v11.8.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/lib/node_modules/node/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/node/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/node/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64 --napi_version=4 --node_abi_napi=napi' (1)
  node-pre-gyp ERR! stack     at ChildProcess. (/usr/local/lib/node_modules/node/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 ChildProcess.emit (events.js:197:13)
  node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:978:16)
  node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
  node-pre-gyp ERR! System Darwin 18.2.0
  node-pre-gyp ERR! command "/usr/local/lib/node_modules/node/bin/node" "/usr/local/lib/node_modules/node/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/node/lib/node_modules/@aws-amplify/cli/node_modules/fsevents
  node-pre-gyp ERR! node -v v11.8.0
  node-pre-gyp ERR! node-pre-gyp -v v0.10.3
  node-pre-gyp ERR! not ok
  Failed to execute '/usr/local/lib/node_modules/node/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/node/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/node/lib/node_modules/@aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64 --napi_version=4 --node_abi_napi=napi' (1)
  npm WARN graphql-import@0.4.5 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: fsevents@1.2.7 (node_modules/@aws-amplify/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
  
  
*
  
*@aws-amplify/cli@0.1.44
  added 2 packages from 1 contributor, removed 6 packages and updated 29 packages in 57.461s
  

When I install node-pre-gyp and node-gyp separately, I get the same errors.
I have CHMOD 0777 on the project folder and then tried to install again without the -g flag, but same error.
OS: Mojave 10.14.2
Node: v11.8.0
npm: 6.5.0

A: You may also try the following command that worked for me :
sudo npm install -g @aws-amplify/cli --unsafe-perm=true 


A: Fixed.
It seems that there was an issue with my global installation of node and npm, missing/incorrect entries in:


*

*~/.bash_profile

*~/.bashrc


The fix was to totally remove node & npm, the re-install using nvm. I followed these:


*

*https://github.com/brock/node-reinstall/

*https://gist.github.com/d2s/372b5943bce17b964a79
Please note: 


*

*you may need to remove some node or npm files manually

*you may need to upgrade node and/or npm afterwards

*you may need to reinstall individual node packages afterwards.


A: I had a similar issue. I needed to set the python version for some odd reason. Something like 
npm config set python python2.7 && npm install
Amplify needs local resources and needs to be tied to a environment especially if you are switching between them.
Like dev/prod or local dev on a Mac vs some dev in windows.
Look at amplify env add

A: I had node installed via brew so my fix was:

*

*uninstall node completely
brew uninstall --force node


*install node via: https://nodejs.org/es/ which updates PATH automatically


*install amplify:
sudo npm install -g @aws-amplify/cli --unsafe-perm=true

A: This is what I did to solve this:

*

*Re-install node to the latest version. You can do that using the following steps:


- sudo npm cache clean -f (force) clear you npm cache
- sudo npm install -g n install n (this might take a while)
- sudo n stable upgrade to the current stable version


Note that sudo might prompt your password.


*Install amplify:


sudo npm install -g @aws-amplify/cli --unsafe-perm=true

This last process may take a while.

A: EACCES permissions errors when installing packages globally

*

*First uninstall amplify


npm uninstall -g @aws-amplify/cli


*

*or


sudo amplify uninstall


*

*Reinstall npm with a node version manager, I recommend this guide https://tecadmin.net/install-nvm-macos-with-homebrew/


*On command line create a directory for global installations

mkdir ~/.npm-global


*

*Configure npm to use the new directory path:


npm config set prefix '~/.npm-global'


*

*For versions after MacOS Catalina uses nano ~/.zshrc and for versions before this version uses nano ~/.profile and add the next line


export PATH=~/.npm-global/bin:$PATH


*

*On the command line, update your system variables. If you used ~/. zshrc

source ~/.zshrc


*

*If you used ~/. profile

source ~/.profile


*

*Then try to install amplify


npm install -g @aws-amplify/cli


A: While the accepted solution seemed to work initially, I encountered further EACCES: permission error while using amplify-cli. The way I got it solved is by resolving EACESS permissions as recommended by npmjs documentation.
Instructions:

*

*On the command line, in your home directory, create a directory for global installations:

mkdir ~/.npm-global



*Configure npm to use the new directory path:

npm config set prefix '~/.npm-global'



*In your preferred text editor, open or create a ~/.profile file and add this line:

nano ~/.profile
export PATH=~/.npm-global/bin:$PATH



*On the command line, update your system variables:

source ~/.profile



*Test if the added path is working by looking for the string .npm-global/bin in the outpout:

echo $PATH



*Finally, install aws-amplify/cli without using sudo as follows:

npm install -g @aws-amplify/cli

