3
votes

I had installed amplify cli on my laptop and even though it threw errors, I had used the amplify configure command anyway and it worked. But now when I'm trying to do the same thing on a different laptop it is throwing the error "-bash: amplify: command not found". Below is the entire error block :

npm WARN deprecated @types/[email protected]: This is a stub types definition. ora provides its own type definitions, so you do not need this installed.
npm WARN deprecated [email protected]: Use uuid module instead
/Users/.npm-global/bin/amplify -> /Users/.npm-global/lib/node_modules/@aws-amplify/cli/bin/amplify

> [email protected] install /Users/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/snappy
> node-gyp rebuild

gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/snappy/build'
gyp ERR! System Darwin 18.6.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/snappy
gyp ERR! node -v v10.16.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 

> [email protected] install /Users/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/zmq
> node-gyp rebuild

gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/zmq/build'
gyp ERR! System Darwin 18.6.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/zmq
gyp ERR! node -v v10.16.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 

> @aws-amplify/[email protected] postinstall /Users/.npm-global/lib/node_modules/@aws-amplify/cli
> node scripts/post-install.js

Ignore installation errors for optional dependencies: gyp, fs-ext


----------------------------------------
Successfully installed the Amplify CLI
----------------------------------------


Javascript Getting Started - https://aws-amplify.github.io/docs/js/start


Android Getting Started - https://aws-amplify.github.io/docs/android/start


iOS Getting Started - https://aws-amplify.github.io/docs/ios/start


npm WARN @conduitvc/[email protected] requires a peer of leveldown@~1.4.3 but none is installed. You must install peer dependencies yourself.
npm WARN @conduitvc/[email protected] requires a peer of ioredis@^1.15.1 but none is installed. You must install peer dependencies yourself.
npm WARN @conduitvc/[email protected] requires a peer of mongodb@~2.1.4 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/snappy):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/@aws-amplify/cli/node_modules/zmq):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

+ @aws-amplify/[email protected]

amplify commands are working totally fine on the other laptop which spat the same errors as above. I had even tried installing the cli using npm install -g @aws-amplify/cli --unsafe-perm=true as suggested by a user on GitHub. If someone could help me fix this it'd be really great. TIA

2
You may need to do sudo npm install -g ...elethan
Tried that as well. Tried reinstalling node, tried changing the owner using sudo chown -R ownername: /usr/local/lib/node_modules, tried installing typescript (a user on GitHub suggested), and yet none of these worked.boomchickawawa

2 Answers

2
votes

After spending a decent amount of time trying to analyse the errors, the following finally worked for me :

  1. Installed typescript with command sudo npm install -g typescript.

  2. Added /usr/local/bin/node and /usr/local/bin/npm to the path. [To add paths, use command sudo nano /etc/paths, add above paths to the file and save.]

  3. Made sure the admin is in charge to access the file by using the command :

    sudo chown -R ownername: /usr/local/lib/node_modules

  4. Finally installed amplify using this command :

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

By following these steps, even though i'm getting errors, the amplify commands are working.

1
votes

The best way I found was at the end of the npm install, you can see the path that it gets installed too.

/usr/local/Cellar/node/13.8.0/bin/amplify -> /usr/local/Cellar/node/13.8.0/lib/node_modules/@aws-amplify/cli/bin/amplify

you can manually append this to you path by running the command:

export PATH=$PATH:/usr/local/Cellar/node/13.8.0/lib/node_modules/@aws-amplify/cli/bin/