Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

Failed to install 'cordova-hot-code-push-plugin':ReferenceError: error is not defined #137

Closed
diegodotta opened this issue Apr 24, 2016 · 22 comments

Comments

@diegodotta
Copy link

I'm spending few hours trying to install the plugin, but I always receive this message.

Installing dependency packages: { "xml2js": ">=0.4" } Failed to install 'cordova-hot-code-push-plugin':ReferenceError: error is not defined at module.exports (C:\Youper\Tests\TestProject\plugins\cordova-hot-code-push-plugin\scripts\beforePluginInstallHook.js:80:11) at runScriptViaModuleLoader (C:\Users\Youper XPS\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:167:18) at runScript (C:\Users\Youper XPS\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:145:16) at C:\Users\Youper XPS\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:130:20 at _fulfilled (C:\Users\Youper XPS\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:787:54) at self.promiseDispatch.done (C:\Users\Youper XPS\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:816:30) at Promise.promise.promiseDispatch (C:\Users\Youper XPS\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:749:13) at C:\Users\Youper XPS\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:810:14 at flush (C:\Users\Youper XPS\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:108:17) at _combinedTickCallback (internal/process/next_tick.js:67:7) Error: error is not defined

My system info:

  • Win 10
  • Cordova CLI: 6.1.1
  • Gulp version: CLI version 3.9.0
  • Gulp local:
  • Ionic CLI Version: 1.7.14
  • Ionic App Lib Version: 0.7.0
  • Node Version: v5.11.0
  • NPM 3.3.8
  • Python 2.7

Some idea?

@nikDemyankov
Copy link
Member

Uploaded typo fix in the beforePluginInstallHook.js: it was throwing the wrong error. Try to install plugin like this:

cordova plugin add https://github.com/nordnet/cordova-hot-code-push.git

It should now display correct installation error.

@diegodotta
Copy link
Author

diegodotta commented Apr 25, 2016

Awesome Nik, the error is about spawnSync, I found a lot of problems with this and Windows.

Failed to install 'cordova-hot-code-push-plugin':Error: spawnSync npm ENOENT at exports._errnoException (util.js:893:11) at spawnSync (child_process.js:448:20) at module.exports (C:\Youper\Tests\Ionic-Starter-Template-master\plugins\cordova-hot-c ode-push-plugin\scripts\beforePluginInstallHook.js:78:16) at runScriptViaModuleLoader (C:\Users\Youper XPS\AppData\Roaming\npm\node_modules\cord ova\node_modules\cordova-lib\src\hooks\HooksRunner.js:167:18) at runScript (C:\Users\Youper XPS\AppData\Roaming\npm\node_modules\cordova\node_module s\cordova-lib\src\hooks\HooksRunner.js:145:16) at C:\Users\Youper XPS\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-l ib\src\hooks\HooksRunner.js:130:20 at _fulfilled (C:\Users\Youper XPS\AppData\Roaming\npm\node_modules\cordova\node_modul es\q\q.js:787:54) at self.promiseDispatch.done (C:\Users\Youper XPS\AppData\Roaming\npm\node_modules\cor dova\node_modules\q\q.js:816:30) at Promise.promise.promiseDispatch (C:\Users\Youper XPS\AppData\Roaming\npm\node_modul es\cordova\node_modules\q\q.js:749:13) at C:\Users\Youper XPS\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:81 0:14 Error: spawnSync npm ENOENT

@nikDemyankov
Copy link
Member

Hmm, will investigate it tomorrow, but since I don't have a Windows machine - might be tricky...

@diegodotta
Copy link
Author

Thanks for your attention, maybe this post give you a clue?
http://stackoverflow.com/questions/27688804/how-do-i-debug-error-spawn-enoent-on-node-js#answer-27688805

@nikDemyankov
Copy link
Member

Yes, thanks.

@oxiao
Copy link

oxiao commented Apr 27, 2016

The reason is the OS environment. On windows, your file at your-App-path\plugins\cordova-hot-code-push-plugin\scripts\beforePluginInstallHook.js line 78,var ps = require('child_process').spawn("npm", ['install'] should be like 'var result = spawnSync(process.platform === "win32" ? "npm.cmd" : "npm", ['install']'.

@oxiao
Copy link

oxiao commented Apr 27, 2016

after changed above, execute cordova plugin add cordova-hot-code-push-plugin again.

@nikDemyankov
Copy link
Member

Thanks for the input, @oxiao . Actually, I was thinking switching to exec, since it should work fine on Windows. But will try your suggestion.

@nikDemyankov
Copy link
Member

@diegodotta uploaded possible fix. Please, try again with command:

cordova plugin add https://github.com/nordnet/cordova-hot-code-push.git

@mattias-altsater
Copy link

The latest fix works for me, however you need to do the same fix in checkCliDependency() for "cordova-hcp".

@nikDemyankov
Copy link
Member

Great! Yes, and also for local dev plugin. Just wanted to know if it works.

@nikDemyankov
Copy link
Member

@rmswenson are you sure, that .cmd is required for cordova-hcp? Is it failing when cordova-hcp is actually installed?

@mattias-altsater
Copy link

Yes, the test is failing for me when it's only cordova-hcp, i.e. I see the instructions for how to install it, even though it is installed.

@nikDemyankov
Copy link
Member

Understood, thanks.

@diegodotta
Copy link
Author

Awesome @nikDemyankov, first plugin added with success!! 💃

@nikDemyankov
Copy link
Member

Good! Thanks to @oxiao for providing the fix and everyone for testing :)

Uploaded new version on npm, closing this issue. For checkCliDependency() I've created a separate issue - #141. Likely, it's not critical.

@jnccneto
Copy link

Hi

I just tried to install on cordova 6.3.0 on Linux but getting the same errors like here is there a new solution?

Failed to install 'cordova-hot-code-push-plugin':TypeError: undefined is not a function
at module.exports (xxxxx cordova-hot-code-push-plugin/scripts/beforePluginInstallHook.js:79:16)

@nikDemyankov
Copy link
Member

Hi,

What version of node and npm you are using?

@jnccneto
Copy link

$ node -v
v0.10.42
$ npm -v
1.3.6

@nikDemyankov
Copy link
Member

The error you are having is because of the too low node version. Try to update to node v4.2 and npm v2.14. Or newer.

@jnccneto
Copy link

Yep
I had the Fedora repo nodejs rpm that was quite dated.
used this repo for updating nodejs:
https://github.com/nodesource/distributions
and install went ok
Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants