2023.04.24 | admin | 231次围观
我试图通过不同的方式更新npm (控制台和npm-windows-升级),最终得到了多个安装卸载 找不到路径,并决定卸载所有设备,清除路径,然后重新启动。
通过的安装程序安装最新的lts版本后,将正确显示npm和节点版本。
node -v
v16.14.2
npm -v
8.5.0
现在运行npm install会导致错误
Error: Cannot find module 'are-we-there-yet'
Require stack:
npm ERR! - C:\Users\Kilian\git\FooBar\node_modules\npmlog\log.js
npm ERR! - C:\Users\Kilian\git\FooBar\node_modules\@mapbox\node-pre-gyp\lib\node-pre-gyp.js
npm ERR! - C:\Users\Kilian\git\FooBar\node_modules\@mapbox\node-pre-gyp\lib\main.js
npm ERR! - C:\Users\Kilian\git\FooBar\node_modules\@mapbox\node-pre-gyp\bin\node-pre-gyp
npm ERR! at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
...
code: 'MODULE_NOT_FOUND',
复制
C:\Program Files\nodejs安装目录:
中。
PS C:\Users\Kilian\git\FooBar> npm config ls -l
; "default" config from default values
_auth = (protected)
access = null
all = false
allow-same-version = false
also = null
audit = true
audit-level = null
auth-type = "legacy"
before = null
bin-links = true
browser = null
ca = null
cache = "C:\\Users\\Kilian\\AppData\\Local\\npm-cache"
cache-max = null
cache-min = 0
cafile = null
call = ""
cert = null
ci-name = null
cidr = null
color = true
commit-hooks = true
depth = null
description = true
dev = false
diff = []
diff-dst-prefix = "b/"
diff-ignore-all-space = false
diff-name-only = false
diff-no-prefix = false
diff-src-prefix = "a/"
diff-text = false
diff-unified = 3
dry-run = false
editor = "notepad.exe"
engine-strict = false
fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
fetch-timeout = 300000
force = false
foreground-scripts = false
format-package-lock = true
fund = true
git = "git"
git-tag-version = true
global = false
global-style = false
globalconfig = "C:\\Users\\Kilian\\AppData\\Roaming\\npm\\etc\\npmrc"
heading = "npm"
https-proxy = null
if-present = false
ignore-scripts = false
include = []
include-staged = false
include-workspace-root = false
init-author-email = ""
init-author-name = ""
init-author-url = ""
init-license = "ISC"
init-module = "C:\\Users\\Kilian\\.npm-init.js"
init-version = "1.0.0"
init.author.email = ""
init.author.name = ""
init.author.url = ""
init.license = "ISC"
init.module = "C:\\Users\\Kilian\\.npm-init.js"
init.version = "1.0.0"
json = false
key = null
legacy-bundling = false
legacy-peer-deps = false
link = false
local-address = null
location = "user"
lockfile-version = null
loglevel = "notice"
logs-max = 10
; long = false ; overridden by cli
maxsockets = 15
message = "%s"
metrics-registry = "https://registry.npmjs.org/"
node-options = null
node-version = "v16.14.2"
noproxy = [""]
npm-version = "8.5.0"
offline = false
omit = []
only = null
optional = null
otp = null
pack-destination = "."
package = []
package-lock = true
package-lock-only = false
parseable = false
prefer-offline = false
prefer-online = false
; prefix = "C:\\Program Files\\nodejs" ; overridden by builtin
preid = ""
production = null
progress = true
proxy = null
read-only = false
rebuild-bundle = true
registry = "https://registry.npmjs.org/"
save = true
save-bundle = false
save-dev = false
save-exact = false
save-optional = false
save-peer = false
save-prefix = "^"
save-prod = false
scope = ""
script-shell = null
searchexclude = ""
searchlimit = 20
searchopts = ""
searchstaleness = 900
shell = "C:\\WINDOWS\\system32\\cmd.exe"
shrinkwrap = true
sign-git-commit = false
sign-git-tag = false
sso-poll-frequency = 500
sso-type = "oauth"
strict-peer-deps = false
strict-ssl = true
tag = "latest"
tag-version-prefix = "v"
timing = false
tmp = "C:\\Users\\Kilian\\AppData\\Local\\Temp"
umask = 0
unicode = true
update-notifier = true
usage = false
user-agent = "npm/{npm-version} node/{node-version} {platform} {arch} workspaces/{workspaces} {ci}"
userconfig = "C:\\Users\\Kilian\\.npmrc"
version = false
versions = false
viewer = "browser"
which = null
workspace = []
workspaces = null
yes = null
; "builtin" config from C:\Program Files\nodejs\node_modules\npm\npmrc
prefix = "C:\\Users\\Kilian\\AppData\\Roaming\\npm"
; "user" config from C:\Users\Kilian\.npmrc
python = "C:\\Users\\Kilian\\.windows-build-tools\\python27\\python.exe"
; "cli" config from command line options
long = true
复制
我有点不明白为什么国家预防机制找不到正确的模块。是否必须显式设置到nodejs目录的路径卸载 找不到路径,是否存在上次安装遗留的配置文件冲突?
我想了解罪魁祸首,以便它可以正确地修复,而不会引起问题的全球安装软件包线。
控制台中运行的Npm实际上是与nodejs一起安装的:
PS C:\Users\Kilian\git\FooBar> gcm npm
CommandType Name Version Source
----------- ---- ------- ------
Application npm.cmd 0.0.0.0 C:\Program Files\nodejs\npm.cmd
复制
版权声明
本文仅代表作者观点。
本文系作者授权发表,未经许可,不得转载。
发表评论