使用npm安装软件包时,无法读取未定义的属性“resolve”

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (1)
  • 关注 (0)
  • 查看 (44)

我不能使用npm在我的Windows 10机器上做任何事情。我总是得到:npm ERR!无法读取undefined的属性'resolve'。

如果重要的话,我正在使用VSCode。

npm install npm -g

给了我和“npm i”相同的信息。我卸载了Node并重新安装了两次,但没有帮助。我删除了唯一的开发目录中的node-modules目录。我没有其他想法。请帮忙

这就是现在完整的日志:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'i' ]
2 info using npm@6.9.0
3 info using node@v10.16.0
4 verbose npm-session c94eba96e7c1121e
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall wordgame@1.0.0
7 info lifecycle wordgame@1.0.0~preinstall: wordgame@1.0.0
8 silly install loadCurrentTree
9 silly install readLocalPackageData
10 timing stage:loadCurrentTree Completed in 13ms
11 silly install loadIdealTree
12 silly install cloneCurrentTreeToIdealTree
13 timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms
14 silly install loadShrinkwrap
15 timing stage:loadIdealTree:loadShrinkwrap Completed in 76ms
16 silly install loadAllDepsIntoIdealTree
17 silly fetchPackageMetaData error for typescript@^3.5.1 Cannot read property 'resolve' of undefined
18 silly fetchPackageMetaData error for typescript@^3.5.1 Cannot read property 'resolve' of undefined
19 timing stage:rollbackFailedOptional Completed in 0ms
20 timing stage:runTopLevelLifecycles Completed in 223ms
21 silly saveTree wordgame@1.0.0
21 silly saveTree +-- @types/express@4.16.1
21 silly saveTree | +-- @types/body-parser@1.17.0
21 silly saveTree | | +-- @types/connect@3.4.32
21 silly saveTree | | | `-- @types/node@10.12.18
21 silly saveTree | | `-- @types/node@10.12.18
21 silly saveTree | +-- @types/express-serve-static-core@4.16.1
21 silly saveTree | | `-- @types/range-parser@1.2.3
21 silly saveTree | `-- @types/serve-static@1.13.2
21 silly saveTree |   `-- @types/mime@2.0.0
21 silly saveTree +-- @types/node@10.12.18
21 silly saveTree +-- @types/seedrandom@2.4.27
21 silly saveTree +-- @types/socket.io@2.1.2
21 silly saveTree +-- @types/ws@6.0.1
21 silly saveTree | `-- @types/events@3.0.0
21 silly saveTree +-- async@2.6.1
21 silly saveTree | `-- lodash@4.17.11
21 silly saveTree +-- bufferutil@4.0.1
21 silly saveTree | `-- node-gyp-build@3.7.0
21 silly saveTree +-- class-transformer@0.2.0
21 silly saveTree +-- express@4.16.4
21 silly saveTree | +-- accepts@1.3.5
21 silly saveTree | | +-- mime-types@2.1.21
21 silly saveTree | | | `-- mime-db@1.37.0
21 silly saveTree | | `-- negotiator@0.6.1
21 silly saveTree | +-- array-flatten@1.1.1
21 silly saveTree | +-- body-parser@1.18.3
21 silly saveTree | | +-- bytes@3.0.0
21 silly saveTree | | +-- content-type@1.0.4
21 silly saveTree | | +-- debug@2.6.9
21 silly saveTree | | | `-- ms@2.0.0
21 silly saveTree | | +-- depd@1.1.2
21 silly saveTree | | +-- http-errors@1.6.3
21 silly saveTree | | | +-- inherits@2.0.3
21 silly saveTree | | | +-- setprototypeof@1.1.0
21 silly saveTree | | | `-- statuses@1.4.0
21 silly saveTree | | +-- iconv-lite@0.4.23
21 silly saveTree | | | `-- safer-buffer@2.1.2
21 silly saveTree | | +-- on-finished@2.3.0
21 silly saveTree | | | `-- ee-first@1.1.1
21 silly saveTree | | +-- qs@6.5.2
21 silly saveTree | | +-- raw-body@2.3.3
21 silly saveTree | | | `-- unpipe@1.0.0
21 silly saveTree | | `-- type-is@1.6.16
21 silly saveTree | |   `-- media-typer@0.3.0
21 silly saveTree | +-- content-disposition@0.5.2
21 silly saveTree | +-- content-type@1.0.4
21 silly saveTree | +-- cookie-signature@1.0.6
21 silly saveTree | +-- cookie@0.3.1
21 silly saveTree | +-- debug@2.6.9
21 silly saveTree | +-- depd@1.1.2
21 silly saveTree | +-- encodeurl@1.0.2
21 silly saveTree | +-- escape-html@1.0.3
21 silly saveTree | +-- etag@1.8.1
21 silly saveTree | +-- finalhandler@1.1.1
21 silly saveTree | | `-- parseurl@1.3.2
21 silly saveTree | +-- fresh@0.5.2
21 silly saveTree | +-- merge-descriptors@1.0.1
21 silly saveTree | +-- methods@1.1.2
21 silly saveTree | +-- on-finished@2.3.0
21 silly saveTree | +-- parseurl@1.3.2
21 silly saveTree | +-- path-to-regexp@0.1.7
21 silly saveTree | +-- proxy-addr@2.0.4
21 silly saveTree | | +-- forwarded@0.1.2
21 silly saveTree | | `-- ipaddr.js@1.8.0
21 silly saveTree | +-- qs@6.5.2
21 silly saveTree | +-- range-parser@1.2.0
21 silly saveTree | +-- safe-buffer@5.1.2
21 silly saveTree | +-- send@0.16.2
21 silly saveTree | | +-- destroy@1.0.4
21 silly saveTree | | `-- mime@1.4.1
21 silly saveTree | +-- serve-static@1.13.2
21 silly saveTree | +-- setprototypeof@1.1.0
21 silly saveTree | +-- statuses@1.4.0
21 silly saveTree | +-- type-is@1.6.16
21 silly saveTree | +-- utils-merge@1.0.1
21 silly saveTree | `-- vary@1.1.2
21 silly saveTree +-- seedrandom@2.4.4
21 silly saveTree +-- socket.io@2.2.0
21 silly saveTree | +-- debug@4.1.1
21 silly saveTree | | `-- ms@2.1.1
21 silly saveTree | +-- engine.io@3.3.2
21 silly saveTree | | +-- base64id@1.0.0
21 silly saveTree | | +-- debug@3.1.0
21 silly saveTree | | +-- engine.io-parser@2.1.3
21 silly saveTree | | | +-- after@0.8.2
21 silly saveTree | | | +-- arraybuffer.slice@0.0.7
21 silly saveTree | | | +-- base64-arraybuffer@0.1.5
21 silly saveTree | | | +-- blob@0.0.5
21 silly saveTree | | | `-- has-binary2@1.0.3
21 silly saveTree | | |   `-- isarray@2.0.1
21 silly saveTree | | `-- ws@6.1.4
21 silly saveTree | |   `-- async-limiter@1.0.0
21 silly saveTree | +-- has-binary2@1.0.3
21 silly saveTree | +-- socket.io-adapter@1.1.1
21 silly saveTree | +-- socket.io-client@2.2.0
21 silly saveTree | | +-- backo2@1.0.2
21 silly saveTree | | +-- component-bind@1.0.0
21 silly saveTree | | +-- component-emitter@1.2.1
21 silly saveTree | | +-- debug@3.1.0
21 silly saveTree | | +-- engine.io-client@3.3.2
21 silly saveTree | | | +-- component-inherit@0.0.3
21 silly saveTree | | | +-- debug@3.1.0
21 silly saveTree | | | +-- has-cors@1.1.0
21 silly saveTree | | | +-- indexof@0.0.1
21 silly saveTree | | | +-- parseqs@0.0.5
21 silly saveTree | | | | `-- better-assert@1.0.2
21 silly saveTree | | | |   `-- callsite@1.0.0
21 silly saveTree | | | +-- parseuri@0.0.5
21 silly saveTree | | | +-- ws@6.1.4
21 silly saveTree | | | +-- xmlhttprequest-ssl@1.5.5
21 silly saveTree | | | `-- yeast@0.1.2
21 silly saveTree | | +-- has-cors@1.1.0
21 silly saveTree | | +-- indexof@0.0.1
21 silly saveTree | | +-- object-component@0.0.3
21 silly saveTree | | +-- parseqs@0.0.5
21 silly saveTree | | +-- parseuri@0.0.5
21 silly saveTree | | +-- socket.io-parser@3.3.0
21 silly saveTree | | | `-- debug@3.1.0
21 silly saveTree | | `-- to-array@0.1.4
21 silly saveTree | `-- socket.io-parser@3.3.0
21 silly saveTree +-- source-map-support@0.5.10
21 silly saveTree | +-- buffer-from@1.1.1
21 silly saveTree | `-- source-map@0.6.1
21 silly saveTree +-- ta-json@2.5.0
21 silly saveTree | `-- reflect-metadata@0.1.12
21 silly saveTree `-- ws@7.0.0
22 verbose stack TypeError: Cannot read property 'resolve' of undefined
22 verbose stack     at regFetch (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-fetch\index.js:76:23)
22 verbose stack     at fetchPackument (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\lib\fetchers\registry\packument.js:42:10)
22 verbose stack     at packument (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\lib\fetchers\registry\packument.js:20:10)
22 verbose stack     at getManifest (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\lib\fetchers\registry\manifest.js:22:10)
22 verbose stack     at manifest (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\lib\fetchers\registry\manifest.js:13:10)
22 verbose stack     at Object.manifest (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\lib\fetchers\registry\index.js:17:12)
22 verbose stack     at Object.Fetcher#manifest [as manifest] (C:\Program Files\nodejs\node_modules\npm\node_modules\genfun\lib\genfun.js:15:38)
22 verbose stack     at manifest (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\lib\fetch.js:23:18)
22 verbose stack     at pinflight (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\manifest.js:24:12)
22 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\promise-inflight\inflight.js:29:24
22 verbose stack     at Promise._execute (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\debuggability.js:313:9)
22 verbose stack     at Promise._resolveFromExecutor (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:483:18)
22 verbose stack     at new Promise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:79:10)
22 verbose stack     at _inflight (C:\Program Files\nodejs\node_modules\npm\node_modules\promise-inflight\inflight.js:28:25)
22 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\promise-inflight\inflight.js:22:14
22 verbose stack     at tryCatcher (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
23 verbose cwd F:\dev\javascript\words
24 verbose Windows_NT 10.0.17134
25 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i"
26 verbose node v10.16.0
27 verbose npm  v6.9.0
28 error Cannot read property 'resolve' of undefined
29 verbose exit [ 1, true ]

提问于
用户回答回答于

我们没有太多信息可以使用(因为Node给出的控制台输出在这种情况下不是很有用),但看起来NPM / Node在安装时搞砸了。

您声明您已经尝试重新安装Node。你当然也应该重新安装NPM(这是一个很好的教程,可以完全删除它们:https//stackoverflow.com/a/20711410/10588376)。

如果你只是忘了提到你也重新安装了NPM而你已经这样做了,我会建议你降级Node。您正在运行v12.4.0,这是Node的最新版本(不太稳定)。您可以下载Node v10.16.0(https://nodejs.org/en/),这是Node 的LTS(长期支持)版本(LTS是Node推荐的版本)。

因为它似乎降级解决了这里的问题:https//stackoverflow.com/a/56512076/10588376(这是针对Linux的,但它也值得在Windows上试一试)

扫码关注云+社区

领取腾讯云代金券