I’m trying to install Serverless CLI with npm install -g serverless
but fails with an error (see below). I have the latest versions of both node and npm. If I run as sudo
it still fails (see below). Any advice welcomed.
node v9.4.0
npm v5.6.0
macOS 10.13.3
Error when running npm install -g serverless
:
Jeremys-iMac:~ jeremy$ npm install -g serverless
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jeremy/.npm/_logs/2018-01-30T14_32_21_908Z-debug.log
Error when running sudo npm install -g serverless
:
Jeremys-iMac:degree-calc-api jeremy$ sudo npm install -g serverless
/usr/local/bin/serverless -> /usr/local/lib/node_modules/serverless/bin/serverless
/usr/local/bin/sls -> /usr/local/lib/node_modules/serverless/bin/serverless
/usr/local/bin/slss -> /usr/local/lib/node_modules/serverless/bin/serverless
> spawn-sync@1.0.15 postinstall /usr/local/lib/node_modules/serverless/node_modules/spawn-sync
> node postinstall
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
path.js:1175
cwd = process.cwd();
^
Error: EACCES: permission denied, uv_cwd
at Object.resolve (path.js:1175:25)
at startup (bootstrap_node.js:174:32)
at bootstrap_node.js:617:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! spawn-sync@1.0.15 postinstall: `node postinstall`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the spawn-sync@1.0.15 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jeremy/.npm/_logs/2018-01-30T14_06_49_435Z-debug.log