Spark Particle CLI installation help

When I tried to install Spark CLI and now with Particle CLI I get the following error messages:

Mac-Attack:node_modules geoff$ sudo npm install -g particle-cli
Password:
    npm WARN engine particle-cli@1.5.11: wanted: {"node":"^0.10.0"} (current: {"node":"0.12.4","npm":"2.10.1"})
    \
    > serialport@1.7.4 install /usr/local/lib/node_modules/particle-cli/node_modules/serialport
    > node-pre-gyp install --fallback-to-build
    
    shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
    sh: node-pre-gyp: command not found
    npm ERR! Darwin 14.3.0
    npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "particle-cli"
    npm ERR! node v0.12.4
    npm ERR! npm  v2.10.1
    npm ERR! file sh
    npm ERR! code ELIFECYCLE
    npm ERR! errno ENOENT
    npm ERR! syscall spawn
    
    npm ERR! serialport@1.7.4 install: `node-pre-gyp install --fallback-to-build`
    npm ERR! spawn ENOENT
    npm ERR! 
    npm ERR! Failed at the serialport@1.7.4 install script 'node-pre-gyp install --fallback-to-build'.
    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-pre-gyp install --fallback-to-build
    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! Please include the following file with any support request:
    npm ERR!     /usr/local/lib/node_modules/npm-debug.log

so I have to install CLI manually.

  1. download the .zip from github https://github.com/spark/particle-cli
  2. move the download folder (particle-cli-master) into /usr/local/lib/node_modules
  3. cd /usr/local/lib/node_modules/particle-cli-master
  4. sudo npm install

That does it, but there is no symbolic link to /usr/local/lib/node_modules/particle-cli-master/particle.sh, so

  1. cd /usr/local/bin
  2. ln -s /usr/local/lib/node_modules/particle-cli-master/particle.sh particle

We’re almost there. Now the file /usr/local/lib/node_modules/particle-cli-master/particle.sh has to be modified:

  1. vi /usr/local/lib/node_modules/particle-cli-master/particle.sh

    #node app.js $*
    node /usr/local/lib/node_modules/particle-cli-master/app.js $*

Comment out node app.js $* and add the same line with the fully-qualified path. Save it.

…and now you can use the particle command as usual. Hope this helps someone out.

It said the issue here:

npm WARN engine particle-cli@1.5.11: wanted: {"node":"^0.10.0"} (current: {"node":"0.12.4","npm":"2.10.1"})

Also the installation issue has to do with the npm package serialport and not particle-cli itself

consider trying in other directory since i see you are in node_modules

@kennethlimcp I’m not sure what you’re saying.

Your nodejs version is higher than what particle-cli wants.

You are in a directory where installation might be an issue. Maybe try to cd to the Desktop and try again.

Sounds like an issue with your PATH try this

sudo ln -s /usr/local/bin/node /usr/bin/node 

then do

sudo npm install -g particle-cli

@kennethlimcp The install instructions at https://github.com/spark/particle-cli say to install node.js. Not a particular version of node.js. Sounds like something in the CLI install needs to be fixed. I spent a few minutes at node.js web site and it is not apparent how to install anything but the latest.

BTW, I stared installation from ~/

@mojtabacazi I already have /usr/bin and /usr/local/bin in my $PATH. But I tried what you suggest and it doesn’t work. Same error message with which I started thread.

I’m up and running. I was just putting some info out there. Following the instructions at https://github.com/spark/particle-cli didn’t work for me.

I feel so noob. I tried everything what it says.

sudo ln -s /usr/local/bin/node /usr/bin/node
ln: /usr/bin/node: Operation not permitted

What’s this?

/usr/local/bin/particle -> /usr/local/lib/node_modules/particle-cli/bin/particle.js

serialport@2.0.4 install /usr/local/lib/node_modules/particle-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/imac/.node-gyp/5.0.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/particle-cli/node_modules/serialport/.node-gyp"
make: *** No rule to make target ../.node-gyp/5.0.0/include/node/common.gypi', needed byMakefile’. Stop.
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 15.0.0
gyp ERR! command “/usr/local/bin/node” “/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “build” “–fallback-to-build” “–module=/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/Release/node-v47-darwin-x64/serialport.node” “–module_name=serialport” "–module_path=/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/Release/node-v47-darwin-x64"
gyp ERR! cwd /usr/local/lib/node_modules/particle-cli/node_modules/serialport
gyp ERR! node -v v5.0.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute ‘/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/Release/node-v47-darwin-x64/serialport.node --module_name=serialport --module_path=/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/Release/node-v47-darwin-x64’ (1)
node-pre-gyp ERR! stack at ChildProcess. (/usr/local/lib/node_modules/particle-cli/node_modules/serialport/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:87:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:172:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:818:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
node-pre-gyp ERR! System Darwin 15.0.0
node-pre-gyp ERR! command “/usr/local/bin/node” “/usr/local/lib/node_modules/particle-cli/node_modules/serialport/node_modules/.bin/node-pre-gyp” “install” "–fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/particle-cli/node_modules/serialport
node-pre-gyp ERR! node -v v5.0.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.13
node-pre-gyp ERR! not ok
Failed to execute ‘/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/Release/node-v47-darwin-x64/serialport.node --module_name=serialport --module_path=/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/Release/node-v47-darwin-x64’ (1)
npm WARN install:serialport serialport@2.0.4 install: node-pre-gyp install --fallback-to-build
npm WARN install:serialport Exit status 1
/usr/local/lib
└── (empty)

npm ERR! code 1

@screenintel Make sure you are an administrator on your machine and use sudo in front of all commands. Also, these instructions worked for me on a couple of Airs:

Continuing the discussion from Tutorial: Particle-cli on Mac OSX [26 Sep 2015]:

Instructions for enabling root access: https://support.apple.com/en-us/HT204012

I sure wish Particle would clean this process up. The CLI is a critical piece of the Particle ecosystem.

Just installed CLI on my new machine using this procedure (see top)
OS X 10.11.3
node 4.4.0
CLI 1.11.0
and it works fine.

I’m still forced to use this procedure because

npm install -g particle-cli

simply doesn’t work. Still blows up on serialport.

Mac-Attack:~ geoff$ sudo npm install -g particle-cli
 
> serialport@2.0.6 install /usr/local/lib/node_modules/particle-cli/node_modules/serialport
> node-pre-gyp install --fallback-to-build

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
sh: node-pre-gyp: command not found
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "particle-cli"
npm ERR! node v4.4.0
npm ERR! npm  v2.14.20
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn

npm ERR! serialport@2.0.6 install: `node-pre-gyp install --fallback-to-build`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the serialport@2.0.6 install script 'node-pre-gyp install --fallback-to-build'.
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-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs serialport
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! 
npm ERR!     npm owner ls serialport
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/geoff/npm-debug.log

The issue is with the admin rights for the npm directory. Try this: https://docs.npmjs.com/getting-started/fixing-npm-permissions

1 Like

@kennethlimcp Worked like a charm! This should be included in the install instructions because the standard node install used 24561 as the owner on /usr/local/lib/node_modules.

And it’s a bit quicker than my solution.