0

为了满足在 Windows 上安装 IBM ApiConnect Developer Toolkit 的先决条件,我尝试npm使用以下命令将我的版本升级到版本 3 -

 npm install -g npm

这是来自 npm-debug.log 的片段 -

2 info using npm@2.15.8
3 info using node@v4.4.7
4 verbose install initial load of C:\Users\arindch.WIPRO\AppData\Roaming\npm\package.json
5 verbose readDependencies loading dependencies from C:\Users\arindch.WIPRO\AppData\Roaming\npm\package.json
6 silly cache add args [ 'npm', null ]
7 verbose cache add spec npm
8 silly cache add parsed spec Result {
8 silly cache add   raw: 'npm',
8 silly cache add   scope: null,
8 silly cache add   name: null,
8 silly cache add   rawSpec: 'npm',
8 silly cache add   spec: 'E:\\Program Files\\nodejs\\npm',
8 silly cache add   type: 'local' }
9 silly addLocalTarball shasum (computed) 3ad8081c76f557dfe66cfd96faedc6b9bf684c51
10 verbose addTmpTarball E:\Program Files\nodejs\npm not in flight; adding
11 verbose correctMkdir C:\Users\arindch.WIPRO\AppData\Roaming\npm-cache correctMkdir not in flight; initializing
12 verbose addTmpTarball validating metadata from E:\Program Files\nodejs\npm
13 verbose tar unpack E:\Program Files\nodejs\npm
14 verbose tar unpacking to C:\Users\ARINDC~1.WIP\AppData\Local\Temp\npm-4064-003cc9de\unpack-dbf5b9c7759f
15 silly gentlyRm C:\Users\ARINDC~1.WIP\AppData\Local\Temp\npm-4064-003cc9de\unpack-dbf5b9c7759f is being purged
16 verbose gentlyRm don't care about contents; nuking C:\Users\ARINDC~1.WIP\AppData\Local\Temp\npm-4064-003cc9de\unpack-dbf5b9c7759f
17 silly gunzTarPerm modes [ '777', '666' ]
18 error not a package E:\Program Files\nodejs\npm
19 error addLocal Could not install E:\Program Files\nodejs\npm
20 verbose stack Error: ENOENT: no such file or directory, open 'C:\Users\ARINDC~1.WIP\AppData\Local\Temp\npm-4064-003cc9de\unpack-dbf5b9c7759f\package.json'
20 verbose stack     at Error (native)
21 verbose cwd E:\Program Files\nodejs
22 error Windows_NT 10.0.10586
23 error argv "E:\\Program Files\\nodejs\\node.exe" "E:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "npm"
24 error node v4.4.7
25 error npm  v2.15.8
26 error path C:\Users\ARINDC~1.WIP\AppData\Local\Temp\npm-4064-003cc9de\unpack-dbf5b9c7759f\package.json
27 error code ENOENT
28 error errno -4058
29 error syscall open
30 error enoent ENOENT: no such file or directory, open 'C:\Users\ARINDC~1.WIP\AppData\Local\Temp\npm-4064-003cc9de\unpack-dbf5b9c7759f\package.json'
30 error enoent This is most likely not a problem with npm itself
30 error enoent and is related to npm not being able to find a file.
31 verbose exit [ -4058, true ]
4

2 回答 2

1

首先,确保您可以通过从提升的 PowerShell 运行以下命令在系统上执行脚本。要以管理员身份运行 PowerShell,请单击开始,搜索 PowerShell,右键单击 PowerShell 和select Run as Administrator. 运行以下命令

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force

然后,要安装和使用此 Windows 升级工具,请运行(也可以从提升的 PowerShell 或 cmd.exe 运行):

npm install --global --production npm-windows-upgrade
npm-windows-upgrade

最后通过键入在普通 cmd.exe 或 PowerShell 中验证 npm 版本

npm -v
于 2016-07-21T22:18:27.620 回答
0

chattopadhya,我遇到了同样的问题,我的解决方案是:

  1. 使用 NPM 3 安装 NodeJS 6.14.0 (LTS)

  2. 安装Windows 构建工具3.1.0 版:npm install -g --production windows-build-tools@3.1.0

  3. 此任务将使您的 NodeJS 进入不安全状态:设置环境变量NODE_TLS_REJECT_UNAUTHORIZED=0以丢弃 TLS 证书验证。(注意:我不能也不会对这种行为在我自己的机器以外的机器上造成的任何后果负责。

  4. 最后安装 API Connect 包没有任何问题:npm install -g apiconnect.

希望能帮助到你。:)

于 2018-11-20T15:51:59.887 回答