aws-sam-cli: sudo npm install fails
Most likely a bug with go-npm
(https://github.com/sanathkr/go-npm) because it handles the installation. But filing a Issue here nevertheless for other folks to be aware of. A fix is on the way.
sudo npm install -g aws-sam-local
Password:
-
> aws-sam-local@0.1.1 postinstall /Users/sanathkr/.nvm/versions/node/v4.3.0/lib/node_modules/aws-sam-local
> go-npm install
Downloading from URL: https://github.com/awslabs/aws-sam-local/releases/download/v0.1.1/sam_0.1.1_darwin_amd64.tar.gz
fs.js:681
return binding.rename(pathModule._makeLong(oldPath),
^
Error: EACCES: permission denied, rename 'bin/sam' -> '/Users/sanathkr/.nvm/versions/node/v4.3.0/bin/sam'
at Error (native)
at Object.fs.renameSync (fs.js:681:18)
at /Users/sanathkr/.nvm/versions/node/v4.3.0/lib/node_modules/aws-sam-local/node_modules/go-npm/bin/index.js:62:12
at /Users/sanathkr/.nvm/versions/node/v4.3.0/lib/node_modules/aws-sam-local/node_modules/go-npm/bin/index.js:51:9
at ChildProcess.exithandler (child_process.js:204:7)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:821:16)
at Socket.<anonymous> (internal/child_process.js:319:11)
at emitOne (events.js:77:13)
npm ERR! Darwin 16.6.0
npm ERR! argv "/Users/sanathkr/.nvm/versions/node/v4.3.0/bin/node" "/Users/sanathkr/.nvm/versions/node/v4.3.0/bin/npm" "install" "-g" "aws-sam-local"
npm ERR! node v4.3.0
npm ERR! npm v2.14.12
npm ERR! code ELIFECYCLE
npm ERR! aws-sam-local@0.1.1 postinstall: `go-npm install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the aws-sam-local@0.1.1 postinstall script 'go-npm install'.
npm ERR! This is most likely a problem with the aws-sam-local package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! go-npm install
npm ERR! You can get their info via:
npm ERR! npm owner ls aws-sam-local
npm ERR! There is likely additional logging output above.
> aws-sam-local@0.1.1 preuninstall /Users/sanathkr/.nvm/versions/node/v4.3.0/lib/node_modules/aws-sam-local
> go-npm uninstall
npm ERR! Please include the following file with any support request:
npm ERR! /Users/sanathkr/workspace/GoWorkspace/src/github.com/awslabs/aws-sam-local/npm-debug.log
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 37 (9 by maintainers)
Commits related to this issue
- Added npm permissions info. Fixes #66 — committed to aws/aws-sam-cli by PaulMaddox 7 years ago
Following fixed for me
npm config set unsafe-perm=true
(Option 1 from that document should fix most ppl’s permissions issues)
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
did the trick from me. Thanks mhart
npm install -g go-npm
thennpm install -g aws-sam-local
worked for meworked for me on mac os
worked for me on Ubuntu 16.04 LTS with
This pull request on
go-npm
should allow for a local rather than global installation ofaws-sam-local
- sanathkr/go-npm#3Installing
aws-sam-local
locally avoids the issues with permissions and let’s you control the version of the module frompackage.json
.Worked for me on Ubuntu 16.04 with
For those who look only on last comment (like me): don’t use
chown -R ...
in case whennpm config get prefix
points to/usr
. Read carefully this article instead: https://docs.npmjs.com/getting-started/fixing-npm-permissionsCan someone please edit or remove this and this!? That’s really dangerous if you’re a fool like me and /usr is your node prefix!
Might be worth adding this to the documentation?
https://docs.npmjs.com/getting-started/fixing-npm-permissions
For some reason mine was some weird user:
A chown to my user fixed it 👍
Use os.tmpdir() ?
npm install -g go-npm then npm install -g aws-sam-local worked for me
Installed Node.js through
apt-get
on Ubuntu 17.04. Also neededsudo ln -s /usr/bin/nodejs /usr/bin/node
for go-npm to work. See: https://github.com/nodejs/node-v0.x-archive/issues/3911Setting unsafe-perm=true did not fix this for me.
Windows 10, gitbash shell, node 8.9.1, npm 5.5.1