I have trouble with spark-cli

I have attempted to install the spark-cli but get the following response. What am I doing wrong?

Steve-Walkers-Mac-mini:~ boulderwalker$ node -v
v0.10.26
Steve-Walkers-Mac-mini:~ boulderwalker$ npm -v
1.4.3
Steve-Walkers-Mac-mini:~ boulderwalker$ npm install -g spark-cli spark cloud login
npm http GET https://registry.npmjs.org/spark-cli
npm http GET https://registry.npmjs.org/spark
npm http GET https://registry.npmjs.org/cloud
npm http GET https://registry.npmjs.org/login
npm http 304 https://registry.npmjs.org/login
npm http 304 https://registry.npmjs.org/spark-cli
npm http 304 https://registry.npmjs.org/spark
npm http 304 https://registry.npmjs.org/cloud
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/login’
npm ERR! { [Error: EACCES, mkdir ‘/usr/local/lib/node_modules/login’]
npm ERR! errno: 3,
npm ERR! code: ‘EACCES’,
npm ERR! path: ‘/usr/local/lib/node_modules/login’,
npm ERR! fstream_type: ‘Directory’,
npm ERR! fstream_path: ‘/usr/local/lib/node_modules/login’,
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:37:53’,
npm ERR! ‘Object.oncomplete (fs.js:107:15)’ ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 13.1.0
npm ERR! command “node” “/usr/local/bin/npm” “install” “-g” “spark-cli” “spark” “cloud” "login"
npm ERR! cwd /Users/boulderwalker
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! path /usr/local/lib/node_modules/login
npm ERR! fstream_path /usr/local/lib/node_modules/login
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/login’
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:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
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:37:53’,
npm ERR! ‘Object.oncomplete (fs.js:107:15)’ ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 13.1.0
npm ERR! command “node” “/usr/local/bin/npm” “install” “-g” “spark-cli” “spark” “cloud” "login"
npm ERR! cwd /Users/boulderwalker
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
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:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/spark’
npm ERR! { [Error: EACCES, mkdir ‘/usr/local/lib/node_modules/spark’]
npm ERR! errno: 3,
npm ERR! code: ‘EACCES’,
npm ERR! path: ‘/usr/local/lib/node_modules/spark’,
npm ERR! fstream_type: ‘Directory’,
npm ERR! fstream_path: ‘/usr/local/lib/node_modules/spark’,
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:37:53’,
npm ERR! ‘Object.oncomplete (fs.js:107:15)’ ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 13.1.0
npm ERR! command “node” “/usr/local/bin/npm” “install” “-g” “spark-cli” “spark” “cloud” "login"
npm ERR! cwd /Users/boulderwalker
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! path /usr/local/lib/node_modules/spark
npm ERR! fstream_path /usr/local/lib/node_modules/spark
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’
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:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/cloud’
npm ERR! { [Error: EACCES, mkdir ‘/usr/local/lib/node_modules/cloud’]
npm ERR! errno: 3,
npm ERR! code: ‘EACCES’,
npm ERR! path: ‘/usr/local/lib/node_modules/cloud’,
npm ERR! fstream_type: ‘Directory’,
npm ERR! fstream_path: ‘/usr/local/lib/node_modules/cloud’,
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:37:53’,
npm ERR! ‘Object.oncomplete (fs.js:107:15)’ ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 13.1.0
npm ERR! command “node” “/usr/local/bin/npm” “install” “-g” “spark-cli” “spark” “cloud” "login"
npm ERR! cwd /Users/boulderwalker
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! path /usr/local/lib/node_modules/cloud
npm ERR! fstream_path /usr/local/lib/node_modules/cloud
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/cloud’
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:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/boulderwalker/npm-debug.log
npm ERR! not ok code 0

It’s difficult to tell from the pasted output, but it looks like you typed npm install -g spark-cli spark cloud login. It should just be npm install -g spark-cli. If it gives you permission issues (like the EACCES mkdir ...), try sudo npm install -g spark-cli. See if it plays a little friendlier after that. If not, let us know what the latest error output is, and we’ll go from there!

1 Like

Later: I have a solution for Ubuntu 12.04 https://community.spark.io/t/how-to-install-spark-cli-on-ubuntu-12-04/3474?u=psb777

Earlier I had written:
I too have a problem installing spark-cli. I’m on a vanilla install of Ubuntu 12.04.

% npm -g install spark-cli
npm http GET https://registry.npmjs.org/spark-cli

npm ERR! Error: failed to fetch from registry: spark-cli
npm ERR! at /usr/share/npm/lib/utils/npm-registry-client/get.js:139:12
npm ERR! at cb (/usr/share/npm/lib/utils/npm-registry-client/request.js:31:9)
npm ERR! at Request._callback (/usr/share/npm/lib/utils/npm-registry-client/request.js:136:18)
npm ERR! at Request.callback (/usr/lib/nodejs/request/main.js:119:22)
npm ERR! at Request. (/usr/lib/nodejs/request/main.js:212:58)
npm ERR! at Request.emit (events.js:88:20)
npm ERR! at ClientRequest. (/usr/lib/nodejs/request/main.js:412:12)
npm ERR! at ClientRequest.emit (events.js:67:17)
npm ERR! at HTTPParser.onIncoming (http.js:1261:11)
npm ERR! at HTTPParser.onHeadersComplete (http.js:102:31)
npm ERR! You may report this log at:
npm ERR! http://bugs.debian.org/npm
npm ERR! or use
npm ERR! reportbug --attach /home/psb/npm-debug.log npm
npm ERR!
npm ERR! System Linux 3.2.0-60-generic
npm ERR! command “node” “/usr/bin/npm” “-g” “install” "spark-cli"
npm ERR! cwd /home/psb
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! message failed to fetch from registry: spark-cli
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/psb/npm-debug.log
npm not ok

I typed sudo npm install -g spark-cli and it worked like a charm. Thanks.

As best as I can tell, maybe you had a temporary issue reaching https://registry.npmjs.org/spark-cli. Can you try opening that link in a web browser and see if you get text starting with {"_id":"spark-cli","_rev":"? If that works, try running npm -g install spark-cli again and see if it gives you the same error.

1 Like

Yes, I had tried that. And saved the file, and I tried to run npm on the file but just to get other errors. And I have tried to run the npm install command several times now over half a day hoping for a transient error.

And now I have tried it using sudo and Ubuntu 13.04 - same error

There’s a solution for npm on Mac in general.

  1. sudo npm config set registry http://registry.npmjs.org/

  2. chown [username] .npm


Anyone interested to debug more and solve the issue can try

http://stackoverflow.com/a/22207869

I worked with a co-worker this afternoon and figured out what the problem was. My “.npm” folder in my home directory was owned by the root user instead of myself. I’m not sure what happened to cause that. Maybe I installed node or npm as the root admin at one point. In any case I just ran “chown [username] .npm” and I was finally able to run “npm install” commands from my projects again!

share|improve this answer
answered Mar 5 at 19:55

TJ Kirchner
4341618

OK, what I have learnt so far:

You will need 0.8 of npm and jnode but Ubuntu only has 0.6
Follow these instructions - read to the end!
http://schier.co/post/install-nodejs-on-ubuntu-server-with-ppa

I was helpfully advised that I would need to first do this
% npm config set registry http://registry.npmjs.org/

before
& npm install spark-cli

And, of course, watch out for permission problems!
And decide whether ot not you will do it under sudo with the -g option or just install as yourself without the -g.

Still not there, quite, but the above is the route I’m taking. Any other tips?

Ubuntu is still on 0.6?! It seems like they should have updated that with 13.04. If you are familiar with compiling from the command line, NodeJS is pretty easy. It’s long, but doesn’t have any dependencies that I can remember. If I have time tonight, I’ll try to spin up an Ubuntu 13.04 virtual machine to write up some quick documentation.

First, make sure you have all the compiling stuff you’ll need:
sudo apt-get install build-essential

If you have git installed:

git clone https://github.com/joyent/node.git cd node git checkout v0.10.26-release ./configure make sudo make install

If you do not have git installed:

wget http://nodejs.org/dist/v0.10.26/node-v0.10.26.tar.gz tar xvfz node-v0.10.26.tar.gz cd node-v0.10.26 ./configure make sudo make install

This has pretty much worked on every Ubuntu or Debian install I’ve used in the past couple of years. Give it a try and let us know how it goes!

1 Like

Even later: There is a better solution which works and is tested by me on Ubuntu 12.04 - it may also work on other Ubuntu releases. See

Later: (I’ve hit the newbie’s 5 posts per thread limit so I’m adding to this post, at the top.) I’ve seemingly addressed the install issue identified below by doing this:

cd /usr/bin
sudo ln -s nodejs node

Watch out - you may already have a /usr/bin/node from another (amateur radio?) package.
I’m not sure the install completed successfully but no problems were reported. I also did

sudo npm -g uninstall spark-cli
sudo npm -g install spark-cli

Earlier: I’m confused about your advise re installing from tarballs or via git. Is that in addition to or instead of ‘apt-get install npm’?

I’ve now tried Ubuntu 13.04 - it’s still only provides npm 0.6 - so doesn’t work. I’ve upgraded one of my boxes to 13.10 and yes all seems to progress well, much newer versions of npm and nodejs are installed, but just as it looks as if “sudo npm -g install spark-clu” is about to complete there is a problem: the relevant output follows. There is a suggestion there is a problem with the serialport module. (I’ve checked as prompted by the below - there is no binary ‘node’ on my system - legacy or not!)

serialport@1.3.1 install /usr/local/lib/node_modules/spark-cli/node_modules/serialport
node-gyp rebuild

/bin/sh: 1: node: not found
gyp: Call to 'node -e "require('nan')"' returned exit status 127. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:431:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Linux 3.11.0-18-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/spark-cli/node_modules/serialport
gyp ERR! node -v v0.10.15
gyp ERR! node-gyp -v v0.10.9
gyp ERR! not ok 
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
 
npm ERR! serialport@1.3.1 install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR! 
npm ERR! Failed at the serialport@1.3.1 install script.
npm ERR! This is most likely a problem with the serialport package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls serialport
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.11.0-18-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "-g" "install" "spark-cli"
npm ERR! cwd /home/psb
npm ERR! node -v v0.10.15
npm ERR! npm -v 1.2.18
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/psb/npm-debug.log
npm ERR! not ok code 0

OK, do this for Ubuntu 12.04 (and maybe for other Ubuntu releases but it’s on 12.04 where I have tested it): https://community.spark.io/t/how-to-install-spark-cli-on-ubuntu-12-04/

I was about to follow up, but then I just saw your other post.

npm is included with a (relatively) recent version of Node.JS. It’s a shame that Ubuntu has let it stagnate when, in fact, it gets updated very frequently. It’s good to know that someone out there cares enough to make an Ubuntu repository to make it easier. I was just too lazy to search for the easy way out. Go figure…

Once I learned about Node.JS, I installed it via apt-get on my Ubuntu server. Then I tried to use something that was in the docs but not in the version I had installed! Since then, I’ve been compiling it from the source repository on GitHub.

1 Like

Compiling from the source is a reliable way to get what you want but not the easiest, esp for newbies or those not comfortable with the build process. I would suggest installing as advised in https://community.spark.io/t/how-to-install-spark-cli-on-ubuntu-12-04/ - All of nodejs and npm and spark-cli now seem to be working fine for me.

I typed both lines and am now able to “npm install” from my home directory. I may have installed npm as root admin just like TJ. I apologize for titling this thread “I have trouble with spark-cli” when it should have been “I am having trouble installing npm.”