aws-sam-cli: macOS npm installation failed
I am unable to install on macOS using npm. I tried installing as sudo and this still did not work.
MacOS 10.12.6 Node v8.1.3 NPM 5.4.2
aws-sam-local@0.2.0 postinstall /usr/local/lib/node_modules/aws-sam-local go-npm install
/usr/local/lib/node_modules/aws-sam-local/node_modules/mkdirp/index.js:90 throw err0; ^
Error: EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules/aws-sam-local/bin’
at Object.fs.mkdirSync (fs.js:890:18)
at Function.sync (/usr/local/lib/node_modules/aws-sam-local/node_modules/mkdirp/index.js:71:13)
at Object.install (/usr/local/lib/node_modules/aws-sam-local/node_modules/go-npm/bin/index.js:159:12)
at Object.<anonymous> (/usr/local/lib/node_modules/aws-sam-local/node_modules/go-npm/bin/index.js:210:17)
at Module._compile (module.js:569:30)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! aws-sam-local@0.2.0 postinstall: go-npm install
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the aws-sam-local@0.2.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (3 by maintainers)
Here is the exact sequence that worked on my local a few seconds ago. Don’t forget to leave sudo out when it comes to step 3.
$ sudo chown -R nico ~/.npm $ sudo chown -R nico /usr/local/lib/node_modules $ npm install --global aws-sam-local
I am on a mac. Per the installation instructions I used npm install -g aws-sam-local.
Hi, I did this workaround (tested on Ubuntu but should work on Mac with node in /usr/local ):
This works and puts the binary in
aws-sam-local/node_modules/.bin/sam
which I then linked to my node bin.Might be related to https://github.com/sanathkr/go-npm/pull/3 which looks merged but not released.
Here’s one way to reproduce the EACCES npm error "Failed at the aws-sam-local@0.2.2 postinstall script ‘go-npm install’ " on Ubuntu (or any Linux once you install basics):
(This is using https://github.com/mklement0/n-install/wiki/System‐wide-installation as opposed to nvm, brew, or manually downloading from https://nodejs.org/download )
I had installed serverless with sudo. In the end, I uninstalled Node and re-installed Node using Homebrew. I had no problems installing aws-sam-local after this.