You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Vladimir Kotikov (JIRA)" <ji...@apache.org> on 2016/08/24 09:15:21 UTC

[jira] [Commented] (CB-11744) `cordova plugin add` does not honor npm registry defined globally

    [ https://issues.apache.org/jira/browse/CB-11744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15434560#comment-15434560 ] 

Vladimir Kotikov commented on CB-11744:
---------------------------------------

The problem comes from the fact that cordova-lib is not using global npm installation. Instead it pulls npm as own dependency and calls it programmatically. Since this is another instance of npm, it is using another builtin config, placed in {{cordova-lib/node_modules/npm/npmrc}} rather than {{C:\Program Files\nodejs\node_modules\npm\npmrc}}.

This is hardly ever will be fixed in cordova-lib since we don't have a way to instruct npm to change the process of configs resolution. However i can see at least 2 workarounds for this:

# pass {{\-\-fetch}} flag to {{cordova plugin add}} command. This will instruct cordova to fetch plugins using {{cordova-fetch}} module which relies on globally installed npm instance. I have verified this and can confirm it works. Note that this might become a default way to fetch the plugins in next versions of cordova.
# use global npm config (in your case it should be placed at {{C:\Program Files\nodejs\etc\npmrc}}) to configure registry rather than builtin one. It specifies a system-wide configuration as well as built-in config and also respected by all npm distributions (including package-level ones)

> `cordova plugin add` does not honor npm registry defined globally
> -----------------------------------------------------------------
>
>                 Key: CB-11744
>                 URL: https://issues.apache.org/jira/browse/CB-11744
>             Project: Apache Cordova
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the default.) 
>          Components: CordovaLib
>    Affects Versions: 6.3.1
>         Environment: Windows 7 x64
> Node 5.1.0
> cordova 6.3.1
> (Also tried using cordova-lib directly; same issue)
>            Reporter: Matt Steele
>              Labels: reproduced, triaged
>
> We have a private NPM registry, configured at the system level (i.e. {{C:\Program Files\nodejs\node_modules\npm\npmrc}}. Attempting to install plugins with the registry defined here fails as it tries to hit the public NPM registry:
> {code}
> C:\Users\IGEN261\code\uit\test\6-hwc\dist\hwc\cordova-project-android>cordova plugin add private-plugin@2.0.5 -d
> No scripts found for hook "before_plugin_add".
> Calling plugman.fetch on plugin "private-plugin@2.0.5"
> Fetching plugin "private-plugin@2.0.5" via npm
> Error: CordovaError: Failed to fetch plugin private-plugin@2.0.5 via registry.
> Probably this is either a connection problem, or plugin spec is incorrect.
> Check your connection and plugin name/version/URL.
> Error: Registry returned 404 for GET on https://registry.npmjs.org/private-plugin
>     at C:\Users\IGEN261\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\plugman\fetch.js:192:33
>     at _rejected (C:\Users\IGEN261\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:797:24)
>     at C:\Users\IGEN261\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:823:30
>     at Promise.when (C:\Users\IGEN261\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:1035:31)
>     at Promise.promise.promiseDispatch (C:\Users\IGEN261\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:741:41)
>     at C:\Users\IGEN261\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:557:44
>     at flush (C:\Users\IGEN261\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:108:17)
>     at doNTCallback0 (node.js:430:9)
>     at process._tickCallback (node.js:359:13)
> {code}
> My config:
> {code}
> >npm config list
> ; cli configs
> long = true
> user-agent = "npm/3.3.12 node/v5.1.0 win32 x64"
> ; userconfig C:\Users\IGEN261\.npmrc
> progress = true
> ; builtin config undefined
> registry = "http://privaterepo.com"
> {code}
> A workaround is to re-specify the registry in my userconfig {{.npmrc}} but plugman should honor the registry when it's set at the global level.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org