You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Ken Naito (JIRA)" <ji...@apache.org> on 2018/06/25 06:02:00 UTC

[jira] [Commented] (CB-14166) Cordova on windows fails when adding plugin

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

Ken Naito commented on CB-14166:
--------------------------------

I can reproduce this issue by using node 6.14.3, 7.2.1, 9.5.0 and 10.5.0.
I think following codes in the cordova-lib/src/plugman/fetch.js are unnecessary.
{code}
                    if (process.platform === 'win32' && parsedSpec.version) {
                        var windowsShellSpecialCharacters = ['&', '\\', '<', '>', '^', '|'];
                        specContainsSpecialCharacters = windowsShellSpecialCharacters.some(function (character) {
                            return parsedSpec.version.indexOf(character);
                        });
                    } 
{code}

This function escapes version code of node module.
On the other hand, the escaped parameter is used in superspawn.js like

{code}
var child = child_process.spawn(cmd, args, spawnOpts);
{code}

where args includes above escaped parameter.
For example, cmd and args are
{code}
cmd = C:\Program Files (x86)\Nodist\bin\npm.exe
args = [ 'install',
  'cordova-plugin-whitelist@"1"',
  '--production',
  '--save' ]
{code}
Note "1" is escaped.

However child_process escapes args by itself.
Therefore escaped args become further escaped.
Then the error occurs.
{code}
npm ERR! code EINVALIDTAGNAME
npm ERR! Invalid tag name ""1"": Tags may not have any characters that encodeURIComponent encodes.
{code}

Node that ""1"" is doubly escaped.

> Cordova on windows fails when adding plugin
> -------------------------------------------
>
>                 Key: CB-14166
>                 URL: https://issues.apache.org/jira/browse/CB-14166
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-windows
>            Reporter: takuya
>            Assignee: Jesse MacFadyen
>            Priority: Blocker
>
> cordova on windows fails to add the plugin.
> This error happens even when cordova-plugin-whitelist.
> Therefore `cordova platform add windows` also fails.
> For example,
> ```
> > cordova create sample
> > cd sample
> > cordova platform add windows
> ```
> brings following error.
> ```
> ...
> Check your connection and plugin name/version/URL.
> Error: C:\Program Files (x86)\Nodist\bin\npm.exe: Command failed with exit code 1 Error output:
> npm ERR! code EINVALIDTAGNAME
> npm ERR! Invalid tag name ""1"": Tags may not have any characters that encodeURIComponent encodes.
> ```
> This error happens for windows environment only.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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