particle-iot/spark-cli

install issue - sudo needed?

Closed this issue · 3 comments

Installing on a mac, I got the following errors:

[Dec 26 10:23:00] $ npm install -g spark-cli
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/spark-cli'
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/spark-cli']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/spark-cli',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/spark-cli',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53',
npm ERR!      'Object.oncomplete (fs.js:108:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 14.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "spark-cli"
npm ERR! cwd /Users/grid/Documents/Processing/projects/controlerTest
npm ERR! node -v v0.10.35
npm ERR! npm -v 1.4.28
npm ERR! path /usr/local/lib/node_modules/spark-cli
npm ERR! fstream_path /usr/local/lib/node_modules/spark-cli
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules/spark-cli'
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53
npm ERR! fstream_stack Object.oncomplete (fs.js:108:15)
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/grid/Documents/Processing/projects/controlerTest/npm-debug.log
npm ERR! not ok code 0

okay... guess I need sudo? (Even though that isn't mentioned on http://docs.spark.io/cli/

[Dec 26 10:23:07] $ sudo npm install -g spark-cli
Password:
/
> serialport@1.4.5 install /usr/local/lib/node_modules/spark-cli/node_modules/serialport
> node-pre-gyp install --fallback-to-build

gyp WARN EACCES user "root" does not have permission to access the dev dir "/Users/grid/.node-gyp/0.10.35"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/spark-cli/node_modules/serialport/.node-gyp"
...

Do I need to do anything here? Move the tmp dir? How could root not have privileges for my home dir?

I guess sudo should work since its a global installation

I've always had to use sudo to get it installed. The repo mentions this:
https://github.com/spark/spark-cli

Need to update docs, thanks!

Dropping this link here for future reference: fixing npm permissions

Pick one of the two steps described in the link above, and you should no longer have permissions errors when installing global npm modules! 😸