Particle Node.js Doesn't work


#1

Hi,

I am running Ubuntu 12.04 and just tried to install particle-api-js and particle-cli with node.js and when I try to run “particle <anything, including nothing>” I get a page full of errors:

#particle
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/SubscribeCommand.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/HelpCommand.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/ConfigCommand.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/SetupCommand TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/FunctionCommand.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/SerialCommand.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/WirelessCommand TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/PublishCommand.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/UpdateCommand.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/BinaryCommand.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/FlashCommand.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/VariableCommand.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/AccessTokenCommands.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/CloudCommands.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/WebhookCommands.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/KeyCommands.js TypeError: Cannot read property 'prototype' of undefined
particle: Unknown command: "help"

I have never used node before and any help would be greatly appreciated.


#2

Can you install again using npm install -g particle-cli?


#3

Same result, saddly


#4

What version of Node is it? I’m pretty sure that the one in the Ubuntu repos for 12.04 is too old. Did you follow this?


#5

I initially used the method on the node.js website which says to run this:

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs

I just remove/purged that install and tried the one you linked and get the same results.

Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/SubscribeCommand.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/HelpCommand.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/ConfigCommand.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/SetupCommand TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/FunctionCommand.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/SerialCommand.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/WirelessCommand TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/PublishCommand.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/UpdateCommand.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/BinaryCommand.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/FlashCommand.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/VariableCommand.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/AccessTokenCommands.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/CloudCommands.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/WebhookCommands.js TypeError: Cannot read property 'prototype' of undefined
Error loading command /home/smd75jr/.npm-global/lib/node_modules/particle-cli/commands/KeyCommands.js TypeError: Cannot read property 'prototype' of undefined
particle: Unknown command: "help"

#6

Can you do a sudo rm -rf /home/smd75jr/.npm-global/lib/node_modules/particle-cli/* and then npm install -g particle-cli --verbose to see if there’s any errors?


#7

Doesn’t show any errors on install, yet same result


#8

Can you cd /home/smd75jr/.npm-global/lib/node_modules/particle-cli and do a node app.js


#9
smd75jr@smd75jr-1:~/.npm-global/lib/node_modules/particle-cli$ node app.js
Potentially unhandled rejection [3] Error: Unknown encoding
    at Buffer.write (buffer.js:382:13)
    at new Buffer (buffer.js:261:26)
    at Object.fs.writeFileSync (fs.js:758:12)
    at Object.settings.saveProfileData (/home/smd75jr/.npm-global/lib/node_modules/particle-cli/settings.js:195:5)
    at /home/smd75jr/.npm-global/lib/node_modules/particle-cli/lib/update-check.js:23:13
    at /home/smd75jr/.npm-global/lib/node_modules/particle-cli/lib/update-check.js:48:4
    at tryCatchReject (/home/smd75jr/.npm-global/lib/node_modules/particle-cli/node_modules/when/lib/makePromise.js:845:30)
    at runContinuation1 (/home/smd75jr/.npm-global/lib/node_modules/particle-cli/node_modules/when/lib/makePromise.js:804:4)
    at Rejected.when (/home/smd75jr/.npm-global/lib/node_modules/particle-cli/node_modules/when/lib/makePromise.js:625:4)
    at Pending.run (/home/smd75jr/.npm-global/lib/node_modules/particle-cli/node_modules/when/lib/makePromise.js:483:13)

^Csmd75jr@smd75jr-1:~/.npm-global/lib/node_modules/particle-cli$ 

Had to Ctrl-C out of it.


#10

wondering what’s going on there… there’s a node_modules folder yeah?


#11

Yup, whats really odd is that it runs beautifully in a Virtualbox Ubuntu 12.04 Server machine, but that’s not really an acceptable dev environment.


#12

What if you sudo rm -rf node_modules and run npm install --verbose?


#13
smd75jr@smd75jr-1:~/.npm-global/lib$ npm install --verbose
npm info it worked if it ends with ok
npm verb cli [ 'node', '/usr/local/bin/npm', 'install', '--verbose' ]
npm info using npm@3.7.2
npm info using node@v0.8.14
npm verb config Skipping project config: /home/smd75jr/.npmrc. (matches userconfig)
npm verb correctMkdir /home/smd75jr/.npm/_locks correctMkdir not in flight; initializing
npm verb lock using /home/smd75jr/.npm/_locks/staging-35f2c77a94e848df.lock for /home/smd75jr/node_modules/.staging
npm verb unbuild node_modules/.staging/particle-api-js-10ec7eec
npm verb gentlyRm don't care about contents; nuking /home/smd75jr/node_modules/.staging/particle-api-js-10ec7eec
npm verb tar unpack /home/smd75jr/.npm/particle-api-js/5.1.1/package.tgz
npm verb tar unpacking to /home/smd75jr/node_modules/.staging/particle-api-js-10ec7eec
npm verb gentlyRm don't care about contents; nuking /home/smd75jr/node_modules/.staging/particle-api-js-10ec7eec
npm verb gentlyRm don't care about contents; nuking /home/smd75jr/node_modules/.staging/particle-api-js-10ec7eec/node_modules
npm info lifecycle particle-api-js@5.1.1~preinstall: particle-api-js@5.1.1
npm info linkStuff particle-api-js@5.1.1
npm verb linkBins particle-api-js@5.1.1
npm verb linkMans particle-api-js@5.1.1
npm info lifecycle particle-api-js@5.1.1~install: particle-api-js@5.1.1
npm info lifecycle particle-api-js@5.1.1~postinstall: particle-api-js@5.1.1
npm verb unlock done using /home/smd75jr/.npm/_locks/staging-35f2c77a94e848df.lock for /home/smd75jr/node_modules/.staging
npm info lifecycle undefined~preinstall: undefined
npm info linkStuff !invalid#1
npm verb linkBins !invalid#1
npm verb linkMans !invalid#1
npm info lifecycle undefined~install: undefined
npm info lifecycle undefined~postinstall: undefined
npm info lifecycle undefined~prepublish: undefined
/home/smd75jr
└── particle-api-js@5.1.1 

npm WARN enoent ENOENT, open '/home/smd75jr/package.json'
npm WARN smd75jr No description
npm WARN smd75jr No repository field.
npm WARN smd75jr No README data
npm WARN smd75jr No license field.
npm verb exit [ 0, true ]
npm info ok

#14

you need to be in the particle-cli folder:

cd /home/smd75jr/.npm-global/lib/node_modules/particle-cli

then: sudo rm -rf node_modules and run npm install --verbose


#15
...a bunch of stuff...

npm verb stack     at module.exports (/usr/local/lib/node_modules/npm/lib/install/diff-trees.js:50:3)
npm verb stack     at Array.1 (/usr/local/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
npm verb cwd /home/smd75jr/.npm-global/lib/node_modules/particle-cli
npm ERR! Linux 3.2.0-98-generic
npm ERR! argv "node" "/usr/local/bin/npm" "install" "--verbose"
npm ERR! node v0.8.14
npm ERR! npm  v3.7.2

npm ERR! Cannot read property 'target' of null
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm verb exit [ 1, true ]

npm ERR! Please include the following file with any support request:
npm ERR!     /home/smd75jr/.npm-global/lib/node_modules/particle-cli/npm-debug.log
smd75jr@smd75jr-1:~/.npm-global/lib/node_modules/particle-cli$

#16

Definitely looks like installation wasn’t successful… It says node v0.8.14 so you might want to check on the installation. That’s probably causing the issue :smile:


#17
$ node --version
v0.8.14

What version should I have?


#18

at least 0.12.7 but 4.2.4+ is recommendable


#19

Just installed v4.3.1 from source and installed particle-cli with sudo npm install -g particle-cli --verbose which seemed to go well, but when I try to run particle <anything> i get:

smd75jr@smd75jr-1:~$ particle login
undefined:1



SyntaxError: Unexpected end of input
    at Object.parse (native)
    at Object.settings.readProfileData (/home/smd75jr/.npm-global/lib/node_modules/particle-cli/settings.js:182:19)
    at Object.settings.whichProfile (/home/smd75jr/.npm-global/lib/node_modules/particle-cli/settings.js:163:11)
    at Object.<anonymous> (/home/smd75jr/.npm-global/lib/node_modules/particle-cli/settings.js:288:10)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)