无法将npm软件包安装到nativescript项目中(..在安装nativescript-nodeify后?)

时间:2017-10-06 17:09:35

标签: android node.js npm nativescript

我遇到的问题让我头疼了好几个小时。我正在开发一个移动应用程序,我在nativescript环境中开发。由于我的应用程序需要解码JSON Web令牌以进行登录,我尝试安装npm jsonwebtoken-package,它似乎与nativescript不兼容。在谷歌之后我发现了我通过

安装的'nativescript-nodeify'插件
tns plugin add nativescript-nodeify

之后一切似乎都运行良好但后来我尝试安装另一个软件包,这给了我以下错误:

npm ERR! code EINVALIDPACKAGENAME
npm ERR! Invalid package name "nativescript-nodeify/node_modules/string_decoder": name can only contain URL-friendly characters

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/jonas/.npm/_logs/2017-10-06T16_24_33_241Z-debug.log

这是日志文件的内容:

0 info it worked if it ends with ok
1 verbose cli [ '/home/jonas/.nvm/versions/node/v6.11.3/bin/node',
1 verbose cli   '/home/jonas/.nvm/versions/node/v6.11.3/bin/npm',
1 verbose cli   'install',
1 verbose cli   'file-system',
1 verbose cli   '--save' ]
2 info using npm@5.4.2
3 info using node@v6.11.3
4 verbose npm-session d7333b71d2cd0141
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 304 https://registry.npmjs.org/file-system 216ms (from cache)
8 silly pacote tag manifest for file-system@latest fetched in 238ms
9 silly install loadIdealTree
10 silly install cloneCurrentTreeToIdealTree
11 silly install loadShrinkwrap
12 silly install loadAllDepsIntoIdealTree
13 silly resolveWithNewModule file-system@2.2.2 checking installable status
14 http fetch GET 304 https://registry.npmjs.org/utils-extend 164ms (from cache)
15 silly pacote range manifest for utils-extend@^1.0.4 fetched in 166ms
16 silly resolveWithNewModule utils-extend@1.0.8 checking installable status
17 http fetch GET 304 https://registry.npmjs.org/file-match 171ms (from cache)
18 silly pacote range manifest for file-match@^1.0.1 fetched in 172ms
19 silly resolveWithNewModule file-match@1.0.2 checking installable status
20 verbose stack Error: Invalid package name "nativescript-nodeify/node_modules/string_decoder": name can only contain URL-friendly characters
20 verbose stack     at invalidPackageName (/home/jonas/.nvm/versions/node/v6.11.3/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:71:15)
20 verbose stack     at Object.Result.setName (/home/jonas/.nvm/versions/node/v6.11.3/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:107:11)
20 verbose stack     at Object.Result (/home/jonas/.nvm/versions/node/v6.11.3/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:96:23)
20 verbose stack     at Function.resolve (/home/jonas/.nvm/versions/node/v6.11.3/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:45:15)
20 verbose stack     at childDependencySpecifier (/home/jonas/.nvm/versions/node/v6.11.3/lib/node_modules/npm/lib/install/deps.js:81:14)
20 verbose stack     at addDependency (/home/jonas/.nvm/versions/node/v6.11.3/lib/node_modules/npm/lib/install/deps.js:532:15)
20 verbose stack     at /home/jonas/.nvm/versions/node/v6.11.3/lib/node_modules/npm/lib/install/deps.js:482:5
20 verbose stack     at /home/jonas/.nvm/versions/node/v6.11.3/lib/node_modules/npm/node_modules/slide/lib/async-map.js:52:35
20 verbose stack     at Array.forEach (native)
20 verbose stack     at /home/jonas/.nvm/versions/node/v6.11.3/lib/node_modules/npm/node_modules/slide/lib/async-map.js:52:11
20 verbose stack     at Array.forEach (native)
20 verbose stack     at asyncMap (/home/jonas/.nvm/versions/node/v6.11.3/lib/node_modules/npm/node_modules/slide/lib/async-map.js:51:8)
20 verbose stack     at loadDeps (/home/jonas/.nvm/versions/node/v6.11.3/lib/node_modules/npm/lib/install/deps.js:474:3)
20 verbose stack     at Array.<anonymous> (/home/jonas/.nvm/versions/node/v6.11.3/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
20 verbose stack     at LOOP (/home/jonas/.nvm/versions/node/v6.11.3/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:14)
20 verbose stack     at /home/jonas/.nvm/versions/node/v6.11.3/lib/node_modules/npm/node_modules/slide/lib/chain.js:18:7
21 verbose cwd /home/jonas/Dokumente/Telemedizin-Bachelorarbeit-JF/medicalIM
22 verbose Linux 4.4.0-42-generic
23 verbose argv "/home/jonas/.nvm/versions/node/v6.11.3/bin/node" "/home/jonas/.nvm/versions/node/v6.11.3/bin/npm" "install" "file-system" "--save"
24 verbose node v6.11.3
25 verbose npm  v5.4.2
26 error code EINVALIDPACKAGENAME
27 error Invalid package name "nativescript-nodeify/node_modules/string_decoder": name can only contain URL-friendly characters
28 verbose exit [ 1, true ]

我尝试通过

卸载nativescript-nodeify
tns plugin remove nativescript-nodeify

似乎也使用npm-command并失败:

Command failed: npm uninstall nativescript-nodeify --save
npm ERR! code EINVALIDPACKAGENAME
npm ERR! Invalid package name "util/util.js": name can only contain URL-friendly characters

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/jonas/.npm/_logs/2017-10-06T16_01_14_047Z-debug.log

我返回了一些提交(在我安装nodeify之前),npm install命令按预期工作。

由于我需要在我的项目中使用这些软件包,如果有人能够获得解决方案来使nativescript-nodeify正常工作或替代它,那将是非常棒的。

提前谢谢你;)

1 个答案:

答案 0 :(得分:0)

我会遇到同样的问题吗? 您必须删除所有节点模块并在每次遇到此问题时重新安装它。 这是太糟糕的解决方案,但直到现在它才是唯一的解决方案。