首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >清洁安装后npm安装失败,错误:找不到模块“我们还在吗?”

清洁安装后npm安装失败,错误:找不到模块“我们还在吗?”
EN

Stack Overflow用户
提问于 2022-03-30 10:14:54
回答 2查看 675关注 0票数 0

我试图通过不同的方式更新npm (控制台和npm-windows-升级),最终得到了多个安装,并决定卸载所有设备,清除路径,然后重新启动。

通过https://nodejs.org/en/的安装程序安装最新的lts版本后,将正确显示npm和节点版本。

代码语言:javascript
复制
node -v
v16.14.2

npm -v
8.5.0

现在运行npm install会导致错误

代码语言:javascript
复制
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安装目录:

  • NodeJs

  • Are-we-there-yet存在于node_folder C:\Program Files\nodejs\node_modules\npm\node_modules\are-we-there-yet

中。

  • npm prefix -g解析为C:\Users\Kilian\AppData\Roaming\npm

  • C:\Program Files\nodejs\在路径上,没有其他nodejs或npm相关的

代码语言:javascript
复制
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一起安装的:

代码语言:javascript
复制
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
EN

回答 2

Stack Overflow用户

发布于 2022-03-30 12:11:54

在我的例子中,这个问题是在对一个新初始化的回购执行简单npm install之后自行解决的。我不知道这是否最终解决了这个问题,或者它是否是别的什么东西,但现在它又起作用了。

票数 1
EN

Stack Overflow用户

发布于 2022-03-30 13:19:41

很好你解决了这个问题!

这可能与某些缓存问题或Packy-lock.json内容有关,下次发生时,您可以尝试删除锁文件和/或清理npm缓存。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71675362

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档