节点错误无法读取未定义的属性“ resolve”
我正在使用reactjs并且无法使用安装任何软件包npm install
。我收到的错误消息是:
npm ERR! Cannot read property 'resolve' of undefinednpm ERR! A complete log of this run can be found in:
npm ERR! /home/stash/.npm/_logs/2019-03-11T10_07_30_264Z-debug.log
当我这样做时npm install -verbose
:
npm info it worked if it ends with oknpm verb cli [ '/usr/local/bin/node',
npm verb cli '/usr/local/bin/npm',
npm verb cli 'install',
npm verb cli '-verbose' ]
npm info using npm@6.7.0
npm info using node@v11.10.1
npm verb npm-session 869376d36eca27b5
npm info lifecycle proj-lite@1.0.0-alpha.6~preinstall: proj-lite@1.0.0-alpha.6
npm timing stage:loadCurrentTree Completed in 22ms
npm timing stage:loadIdealTree:cloneCurrentTree Completed in 1ms
npm timing stage:loadIdealTree:loadShrinkwrap Completed in 1231ms
npm timing stage:rollbackFailedOptional Completed in 1ms
npm timing stage:runTopLevelLifecycles Completed in 2661ms
npm verb stack TypeError: Cannot read property 'resolve' of undefined
npm verb stack at regFetch (/usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js:76:23)
npm verb stack at fetchPackument (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/packument.js:42:10)
npm verb stack at packument (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/packument.js:20:10)
npm verb stack at getManifest (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/manifest.js:22:10)
npm verb stack at manifest (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/manifest.js:13:10)
npm verb stack at Object.manifest (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/index.js:17:12)
npm verb stack at Object.Fetcher#manifest [as manifest] (/usr/local/lib/node_modules/npm/node_modules/genfun/lib/genfun.js:15:38)
npm verb stack at manifest (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetch.js:23:18)
npm verb stack at pinflight (/usr/local/lib/node_modules/npm/node_modules/pacote/manifest.js:24:12)
npm verb stack at /usr/local/lib/node_modules/npm/node_modules/promise-inflight/inflight.js:29:24
npm verb stack at Promise._execute (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/debuggability.js:313:9)
npm verb stack at Promise._resolveFromExecutor (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:483:18)
npm verb stack at new Promise (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:79:10)
npm verb stack at _inflight (/usr/local/lib/node_modules/npm/node_modules/promise-inflight/inflight.js:28:25)
npm verb stack at /usr/local/lib/node_modules/npm/node_modules/promise-inflight/inflight.js:22:14
npm verb stack at tryCatcher (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
npm verb cwd /var/www/html/lite-proj/lite-proj
npm verb Linux 4.4.0-142-generic
npm verb argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-verbose"
npm verb node v11.10.1
npm verb npm v6.7.0
npm ERR! Cannot read property 'resolve' of undefined
npm verb exit [ 1, true ]
npm timing npm Completed in 3862ms
npm ERR! A complete log of this run can be found in:
npm ERR! /home/stash/.npm/_logs/2019-03-11T10_12_15_921Z-debug.log
我什至无法卸载npm并重新安装它,因为在尝试卸载时出现相同的错误。这里有什么问题,我该如何解决?
回答:
该错误的原因可能是全局软件包和节点版本冲突。我卸载了node和npm,然后重新安装了它们。
删除nodejs和相关的软件包(如npm):
sudo apt-get purge --auto-remove nodejs
Nodejs和npm将文件保留在系统中,这可能会在重新安装期间引起问题。我也必须删除它们。
尽管手动删除软件包是一种不好的做法(这可能会导致软件包管理器出现问题),但这对我的情况有所帮助。此答案显示了如何手动删除nodejs和相关文件。
要重新安装它们:
sudo apt-get updatesudo apt-get install nodejs
sudo apt-get install npm
以上是 节点错误无法读取未定义的属性“ resolve” 的全部内容, 来源链接: utcz.com/qa/424277.html