dpa99c / cordova-custom-config

Cordova/Phonegap plugin to update platform configuration files based on preferences and config-file data defined in config.xml
317 stars 85 forks source link

Failed to install 'cordova-custom-config':undefined #111

Closed zwacky closed 7 years ago

zwacky commented 7 years ago
# ionic plugin add cordova-custom-config

Fetching plugin "cordova-custom-config" via npm
Installing "cordova-custom-config" for android
cordova-custom-config: npm dependencies missing - installing
Failed to install 'cordova-custom-config':undefined
Error: Error installing npm dependencies: Error: Command failed: npm install cordova-custom-config
npm ERR! code ENOSELF
npm ERR! Refusing to install package with name "cordova-custom-config" under a package
npm ERR! also called "cordova-custom-config". Did you name your project the same
npm ERR! as the dependency you're installing?
npm ERR! 
npm ERR! For more information, see:
npm ERR!     <https://docs.npmjs.com/cli/install#limitations-of-npms-install-algorithm>

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/zwacky/.npm/_logs/2017-04-12T13_11_47_627Z-debug.log

also throws an error when trying to use ionic plugin add cordova-custom-config@3.1.4. version 2.0.3 works fine.

dpa99c commented 7 years ago

This has been reported before (#86) though I haven't been able to reproduce it, but it seems to be a problem when attempting to install into a project which previously contained an old version of the plugin.

Try cleaning out previous remnants: rm -Rf node_modules/cordova-custom-config and rm -Rf plugins/cordova-custom-config then install.

If still having issues, install with new cordova-fetch option

cordova plugin add cordova-custom-config --fetch

(not sure if ionic CLI supports the --fetch flag yet)

zwacky commented 7 years ago

Hey @dpa99c, I tried all variations and still get an error.

# cordova plugin add cordova-custom-config --fetch

Error: Failed to fetch plugin cordova-custom-config via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
dpa99c commented 7 years ago

Seems like you have some weirdness with your dev environment if it can't find the plugin via the registry - it's there. Here's what I get:

$ cordova -v
6.5.0

$ cordova plugin add cordova-custom-config --fetch --verbose
No scripts found for hook "before_plugin_add".
No version specified for cordova-custom-config, retrieving version from config.xml
Calling plugman.fetch on plugin "cordova-custom-config@*"
Running command: cmd "/s /c "G:\Users\dpa99_000\AppData\Roaming\npm\npm.cmd install cordova-custom-config@*""
Command finished with error code 0: cmd /s /c "G:\Users\dpa99_000\AppData\Roaming\npm\npm.cmd install cordova-custom-config@*"
Copying plugin "D:\Git\cordova-custom-config-example\node_modules\cordova-custom-config" => "D:\Git\cordova-custom-config-example\plugins\cordova-custom-config"
Calling plugman.install on plugin "D:\Git\cordova-custom-config-example\plugins\cordova-custom-config" for platform "android
Installing "cordova-custom-config" for android
Running command: cmd "/s /c "D:\Git\cordova-custom-config-example\platforms\android\cordova\version.bat""
Command finished with error code 0: cmd /s /c "D:\Git\cordova-custom-config-example\platforms\android\cordova\version.bat"
Finding scripts for "before_plugin_install" hook from plugin cordova-custom-config on android platform only.
No scripts found for hook "before_plugin_install".
Install start for "cordova-custom-config" on android.
Beginning processing of action stack for android project...
Action stack processing complete.
Install complete for cordova-custom-config on android.
Finding scripts for "after_plugin_install" hook from plugin cordova-custom-config on android platform only.
Executing script found in plugin cordova-custom-config for hook "after_plugin_install": plugins\cordova-custom-config\hooks\resolveDependencies.js
Resolving module name for child_process => child_process
Resolving module name for fs => fs
Resolving module name for path => path
Resolving module name for q => q
cordova-custom-config: npm dependencies already installed
No scripts found for hook "after_plugin_add".

$ cordova prepare android
cordova-custom-config: Skipping auto-restore of config file backup(s)
cordova-custom-config: Applied custom config from config.xml to D:\Git\cordova-custom-config-example\platforms\android\AndroidManifest.xml

$ node -v
v7.3.0

$ npm -v
3.10.10
dpa99c commented 7 years ago

Closed due to no response from OP

zwacky commented 7 years ago
$ cordova -v
6.5.0

$ node -v
v6.9.5

$ npm -v
4.4.4

the thing that baffles me the most is this:

$ ionic plugin add cordova-custom-config

[...]

cordova-custom-config: npm dependencies missing - installing

npm ERR! Refusing to install package with name "cordova-custom-config" under a package
npm ERR! also called "cordova-custom-config". Did you name your project the same
npm ERR! as the dependency you're installing?

can this be caused by other plugins somehow?

dpa99c commented 7 years ago

can this be caused by other plugins somehow?

You could eliminate that as a possible cause by trying with the example project which is what I tested it with: clone the repo and try ionic plugin add cordova-custom-config then see if it works.

zwacky commented 7 years ago

The issue was on my part all along. my package.json was completely off. I solved it by creating a new one via ionic state save. Thank you for pointing me in the right direction.

I think #86 must have the same package.json issue that I had or that they run cordova plugin add cordova-custom-plugin in the actual cordova-custom-plugin directory(?!). Cheers!