Tutorial: Particle-cli on Mac OSX [26 Sep 2015]

This worked for me:

sudo npm cache clean -f
sudo npm install -g n
sudo n 0.10.36

Found here http://stackoverflow.com/questions/28486231/how-to-properly-install-node-inspector-on-osx-yosemite-with-node-js-0-12

Found this thread after having similar errors on OSX Yosemite 10.10.5:

npm install -g particle-cli
npm WARN install:core-util-is@1.0.1 ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/particle-cli/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is' -> '/usr/local/lib/node_modules/particle-cli/node_modules/core-util-is'
[...SNIP...]
npm WARN install:strip-ansi@2.0.1 ENOENT: no such file or directory, chmod '/usr/local/lib/node_modules/particle-cli/node_modules/readline2/node_modules/strip-ansi/cli.js'
[...SNIP...]
└── (empty)

npm ERR! code 1

However my brew was already updated previously:

brew update && brew upgrade
$ node --version
v5.0.0
$ npm --version
3.3.9

All I had to do was clean up my node cache:

npm uninstall -g particle-cli
sudo npm cache clean -f

And the install succeeded without incident:

npm install -g particle-cli
particle login
2 Likes

I've got the same versions yet I'm still unable to execute node-pre-gyp.

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 v0.13.1
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/Cellar/node/5.0.0/bin/node /usr/local/lib/node_modules/node-gyp/bin/node-gyp.js configure --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 13.4.0
node-pre-gyp ERR! command "/usr/local/Cellar/node/5.0.0/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

Can you downgrade to nodejs v4.x.x. and try again?

What version of nodejs work with with OS X 10.10.5 ?
$ particle login gives the error -bash: particle: command not found.
My version of nodejs is :node -v : v4.2.6

V4 should work fine too. Did you notice any error installing the CLI?

The install went smoothly but the Terminal Activity cursor would keep spinning. I let it go for 2 hours and then exited the Terminal. All of the files appeared to be there (but I have no way of really knowing). How long should it take to install?

It should only take 1-2 minutes at most. Can you cancel it and try again?

npm install -g particle-cli --verbose

That did the trick! It installed properly and I was able to login. Thanks so much. :blush:

When I try to run;

sudo npm install -g particle-cli

I get the following result;

npm WARN excluding symbolic link test/server/static/ie8-polyfill.js -> ../../../ie8-polyfill.js
npm WARN deprecated node-uuid@1.4.7: use uuid module instead
npm WARN excluding symbolic link test/server/static/ie8-polyfill.js -> ../../../ie8-polyfill.js
/usr/local/bin/particle -> /usr/local/lib/node_modules/particle-cli/bin/particle.js

> serialport@4.0.7 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
/usr/local/lib
└── (empty)

npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "particle-cli"
npm ERR! node v7.6.0
npm ERR! npm  v4.3.0
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn

npm ERR! serialport@4.0.7 install: `node-pre-gyp install --fallback-to-build`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the serialport@4.0.7 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, 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 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/noofny/.npm/_logs/2017-03-13T08_47_43_526Z-debug.log

node -v : 7.6.0
npm -v : 4.3.0
OSX : 10.11.6

Have tried a bunch of things suggested in this post but cannot get this thing going, I’m clearly new to Node, can anyone please halp?!

Try doing sudo npm install -g serialport first

Thanks, but same type of errors about permissions...

sudo npm install -g serialport

/usr/local/bin/serialport-term -> /usr/local/lib/node_modules/serialport/bin/serialport-terminal.js
/usr/local/bin/serialport-list -> /usr/local/lib/node_modules/serialport/bin/serialport-list.js

> serialport@4.0.7 install /usr/local/lib/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.6.0
npm ERR! argv "/usr/local/Cellar/node/7.7.2/bin/node" "/usr/local/bin/npm" "install" "-g" "serialport"
npm ERR! node v7.7.2
npm ERR! npm  v4.1.2
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn

npm ERR! serialport@4.0.7 install: `node-pre-gyp install --fallback-to-build`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the serialport@4.0.7 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, 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 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/noofny/npm-debug.log

I have literally spent hours on this, trying every suggestion from using homebrew/not and using nvm/not, trying installing the particle-cli using different versions of node/npm, deleting everything and starting clean, chmod/chown on the entire /usr/local folder and even trying to run OSX as root.

No joy.

Why is this such a disaster on OSX?

I admit I am learning, and that my patience on this particular issue has reached it’s end, so sorry for the rage.

Can you try the instructions here: https://docs.npmjs.com/getting-started/fixing-npm-permissions

The serialport module installation does fail sometimes which is why Particle-CLI failed install.

Sorry for the friction! We are here to help :slight_smile:

Thanks @kennethlimcp. So after looking at that helpful article, I saw it contains the same matrix of solutions I have already read and tried without success. Regardless, I optimistically followed "option 1", with the same results;

sudo npm install -g serialport


/usr/local/bin/serialport-list -> /usr/local/lib/node_modules/serialport/bin/serialport-list.js
/usr/local/bin/serialport-term -> /usr/local/lib/node_modules/serialport/bin/serialport-terminal.js

> serialport@4.0.7 install /usr/local/lib/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.6.0
npm ERR! argv "/usr/local/Cellar/node/7.7.2/bin/node" "/usr/local/bin/npm" "install" "-g" "serialport"
npm ERR! node v7.7.2
npm ERR! npm  v4.1.2
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn

npm ERR! serialport@4.0.7 install: `node-pre-gyp install --fallback-to-build`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the serialport@4.0.7 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, 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 owner ls serialport
npm ERR! There is likely additional logging output above.

Maybe this is also required: (sudo) npm install -g node-gyp

Thanks mate, so I ran that, didn't get any errors (but a tree response I can provide if you need), so then I ran;

sudo npm install -g serialport

and received the same goodness...

/usr/local/bin/serialport-list -> /usr/local/lib/node_modules/serialport/bin/serialport-list.js
/usr/local/bin/serialport-term -> /usr/local/lib/node_modules/serialport/bin/serialport-terminal.js

> serialport@4.0.7 install /usr/local/lib/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.6.0
npm ERR! argv "/usr/local/Cellar/node/7.7.2/bin/node" "/usr/local/bin/npm" "install" "-g" "serialport"
npm ERR! node v7.7.2
npm ERR! npm  v4.1.2
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn

npm ERR! serialport@4.0.7 install: `node-pre-gyp install --fallback-to-build`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the serialport@4.0.7 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, 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 owner ls serialport
npm ERR! There is likely additional logging output above.

What does npm list -g --depth=0 say?

Can you also try to cd to your Desktop before running sudo npm install -g particle-cli again?

This is what the terminal outputs, should I run a verbose switch or are there log files that will help?

/usr/local/bin/node-gyp -> /usr/local/lib/node_modules/node-gyp/bin/node-gyp.js
/usr/local/lib
└─┬ node-gyp@3.5.0 
  β”œβ”€β”¬ fstream@1.0.11 
  β”‚ └── inherits@2.0.3 
  β”œβ”€β”¬ glob@7.1.1 
  β”‚ β”œβ”€β”€ fs.realpath@1.0.0 
  β”‚ β”œβ”€β”¬ inflight@1.0.6 
  β”‚ β”‚ └── wrappy@1.0.2 
  β”‚ β”œβ”€β”€ once@1.4.0 
  β”‚ └── path-is-absolute@1.0.1 
  β”œβ”€β”€ graceful-fs@4.1.11 
  β”œβ”€β”¬ minimatch@3.0.3 
  β”‚ └─┬ brace-expansion@1.1.6 
  β”‚   β”œβ”€β”€ balanced-match@0.4.2 
  β”‚   └── concat-map@0.0.1 
  β”œβ”€β”¬ mkdirp@0.5.1 
  β”‚ └── minimist@0.0.8 
  β”œβ”€β”¬ nopt@3.0.6 
  β”‚ └── abbrev@1.1.0 
  β”œβ”€β”¬ npmlog@4.0.2 
  β”‚ β”œβ”€β”¬ are-we-there-yet@1.1.2 
  β”‚ β”‚ β”œβ”€β”€ delegates@1.0.0 
  β”‚ β”‚ └─┬ readable-stream@2.2.3 
  β”‚ β”‚   β”œβ”€β”€ buffer-shims@1.0.0 
  β”‚ β”‚   β”œβ”€β”€ core-util-is@1.0.2 
  β”‚ β”‚   β”œβ”€β”€ isarray@1.0.0 
  β”‚ β”‚   β”œβ”€β”€ process-nextick-args@1.0.7 
  β”‚ β”‚   β”œβ”€β”€ string_decoder@0.10.31 
  β”‚ β”‚   └── util-deprecate@1.0.2 
  β”‚ β”œβ”€β”€ console-control-strings@1.1.0 
  β”‚ β”œβ”€β”¬ gauge@2.7.3 
  β”‚ β”‚ β”œβ”€β”€ aproba@1.1.1 
  β”‚ β”‚ β”œβ”€β”€ has-unicode@2.0.1 
  β”‚ β”‚ β”œβ”€β”€ object-assign@4.1.1 
  β”‚ β”‚ β”œβ”€β”€ signal-exit@3.0.2 
  β”‚ β”‚ β”œβ”€β”¬ string-width@1.0.2 
  β”‚ β”‚ β”‚ β”œβ”€β”€ code-point-at@1.1.0 
  β”‚ β”‚ β”‚ └─┬ is-fullwidth-code-point@1.0.0 
  β”‚ β”‚ β”‚   └── number-is-nan@1.0.1 
  β”‚ β”‚ β”œβ”€β”¬ strip-ansi@3.0.1 
  β”‚ β”‚ β”‚ └── ansi-regex@2.1.1 
  β”‚ β”‚ └── wide-align@1.1.0 
  β”‚ └── set-blocking@2.0.0 
  β”œβ”€β”¬ osenv@0.1.4 
  β”‚ β”œβ”€β”€ os-homedir@1.0.2 
  β”‚ └── os-tmpdir@1.0.2 
  β”œβ”€β”¬ request@2.81.0 
  β”‚ β”œβ”€β”€ aws-sign2@0.6.0 
  β”‚ β”œβ”€β”€ aws4@1.6.0 
  β”‚ β”œβ”€β”€ caseless@0.12.0 
  β”‚ β”œβ”€β”¬ combined-stream@1.0.5 
  β”‚ β”‚ └── delayed-stream@1.0.0 
  β”‚ β”œβ”€β”€ extend@3.0.0 
  β”‚ β”œβ”€β”€ forever-agent@0.6.1 
  β”‚ β”œβ”€β”¬ form-data@2.1.2 
  β”‚ β”‚ └── asynckit@0.4.0 
  β”‚ β”œβ”€β”¬ har-validator@4.2.1 
  β”‚ β”‚ β”œβ”€β”¬ ajv@4.11.5 
  β”‚ β”‚ β”‚ β”œβ”€β”€ co@4.6.0 
  β”‚ β”‚ β”‚ └─┬ json-stable-stringify@1.0.1 
  β”‚ β”‚ β”‚   └── jsonify@0.0.0 
  β”‚ β”‚ └── har-schema@1.0.5 
  β”‚ β”œβ”€β”¬ hawk@3.1.3 
  β”‚ β”‚ β”œβ”€β”€ boom@2.10.1 
  β”‚ β”‚ β”œβ”€β”€ cryptiles@2.0.5 
  β”‚ β”‚ β”œβ”€β”€ hoek@2.16.3 
  β”‚ β”‚ └── sntp@1.0.9 
  β”‚ β”œβ”€β”¬ http-signature@1.1.1 
  β”‚ β”‚ β”œβ”€β”€ assert-plus@0.2.0 
  β”‚ β”‚ β”œβ”€β”¬ jsprim@1.3.1 
  β”‚ β”‚ β”‚ β”œβ”€β”€ extsprintf@1.0.2 
  β”‚ β”‚ β”‚ β”œβ”€β”€ json-schema@0.2.3 
  β”‚ β”‚ β”‚ └── verror@1.3.6 
  β”‚ β”‚ └─┬ sshpk@1.11.0 
  β”‚ β”‚   β”œβ”€β”€ asn1@0.2.3 
  β”‚ β”‚   β”œβ”€β”€ assert-plus@1.0.0 
  β”‚ β”‚   β”œβ”€β”€ bcrypt-pbkdf@1.0.1 
  β”‚ β”‚   β”œβ”€β”¬ dashdash@1.14.1 
  β”‚ β”‚   β”‚ └── assert-plus@1.0.0 
  β”‚ β”‚   β”œβ”€β”€ ecc-jsbn@0.1.1 
  β”‚ β”‚   β”œβ”€β”¬ getpass@0.1.6 
  β”‚ β”‚   β”‚ └── assert-plus@1.0.0 
  β”‚ β”‚   β”œβ”€β”€ jodid25519@1.0.2 
  β”‚ β”‚   β”œβ”€β”€ jsbn@0.1.1 
  β”‚ β”‚   └── tweetnacl@0.14.5 
  β”‚ β”œβ”€β”€ is-typedarray@1.0.0 
  β”‚ β”œβ”€β”€ isstream@0.1.2 
  β”‚ β”œβ”€β”€ json-stringify-safe@5.0.1 
  β”‚ β”œβ”€β”¬ mime-types@2.1.14 
  β”‚ β”‚ └── mime-db@1.26.0 
  β”‚ β”œβ”€β”€ oauth-sign@0.8.2 
  β”‚ β”œβ”€β”€ performance-now@0.2.0 
  β”‚ β”œβ”€β”€ qs@6.4.0 
  β”‚ β”œβ”€β”€ safe-buffer@5.0.1 
  β”‚ β”œβ”€β”€ stringstream@0.0.5 
  β”‚ β”œβ”€β”¬ tough-cookie@2.3.2 
  β”‚ β”‚ └── punycode@1.4.1 
  β”‚ β”œβ”€β”€ tunnel-agent@0.6.0 
  β”‚ └── uuid@3.0.1 
  β”œβ”€β”€ rimraf@2.6.1 
  β”œβ”€β”€ semver@5.3.0 
  β”œβ”€β”¬ tar@2.2.1 
  β”‚ └── block-stream@0.0.9 
  └─┬ which@1.2.12 
    └── isexe@1.1.2

Sorry, your original question

npm node-gyp --version
4.1.2