新装的nodejs,直接在项目中执行 npm insatll 报错。
如下是安装的版本信息:
报错日志中信息:
其中 https://chromedriver.storage.googleapis.com/2.27/chromedriver_win32.zip 是可以访问并且下载下来的 但是好像通过命令的时候 就是0kb!
如下是cmd 输出所有配置:
Microsoft Windows [版本 10.0.22000.493]
(c) Microsoft Corporation。保留所有权利。
C:\WINDOWS\system32>npm -v
8.3.1
C:\WINDOWS\system32>node -v
v16.14.0
C:\WINDOWS\system32>npm config ls
; "builtin" config from C:\local\Software\nodejs\node_modules\npm\npmrc
; prefix = "C:\\Users\\Administrator\\AppData\\Roaming\\npm" ; overridden by user
; "user" config from C:\Users\Administrator\.npmrc
cache = "C:\\local\\Software\\nodejs\\node_cache"
prefix = "C:\\local\\Software\\nodejs\\node_global"
registry = "https://registry.npmmirror.com/"
; node bin location = C:\local\Software\nodejs\node.exe
; cwd = C:\WINDOWS\system32
; HOME = C:\Users\Administrator
; Run `npm config ls -l` to show all defaults.
C:\WINDOWS\system32>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\\Administrator\\AppData\\Local\\npm-cache" ; overridden by user
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:\\local\\Software\\nodejs\\node_global\\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\\Administrator\\.npm-init.js"
init-version = "1.0.0"
init.author.email = ""
init.author.name = ""
init.author.url = ""
init.license = "ISC"
init.module = "C:\\Users\\Administrator\\.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.npmmirror.com/"
node-options = null
node-version = "v16.14.0"
noproxy = [""]
npm-version = "8.3.1"
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:\\local\\Software\\nodejs" ; overridden by user
preid = ""
production = null
progress = true
proxy = null
read-only = false
rebuild-bundle = true
; registry = "https://registry.npmjs.org/" ; overridden by user
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\\ADMINI~1\\AppData\\Local\\Temp"
umask = 0
unicode = false
update-notifier = true
usage = false
user-agent = "npm/{npm-version} node/{node-version} {platform} {arch} workspaces/{workspaces} {ci}"
userconfig = "C:\\Users\\Administrator\\.npmrc"
version = false
versions = false
viewer = "browser"
which = null
workspace = []
workspaces = null
yes = null
; "builtin" config from C:\local\Software\nodejs\node_modules\npm\npmrc
; prefix = "C:\\Users\\Administrator\\AppData\\Roaming\\npm" ; overridden by user
; "user" config from C:\Users\Administrator\.npmrc
cache = "C:\\local\\Software\\nodejs\\node_cache"
prefix = "C:\\local\\Software\\nodejs\\node_global"
registry = "https://registry.npmmirror.com/"
; "cli" config from command line options
long = true
C:\WINDOWS\system32>
版本太新,我有个项目就是要用10.16.3的版本 可以试试换旧的
我也换了一个低版本的 经过一系列百度安装终于可以了。感谢
加上国内镜像源试试,在 .npmrc 中添加
registry=https://registry.npmmirror.com
加了还是不行
而且我之前设置过淘宝镜像的,跟这不是一个效果嘛?
cmd 中执行如下:
npm config set registry https://registry.npm.taobao.org
@当个胖子: 详见 原淘宝 npm 域名即将停止解析
@dudu: 也重新设置了镜像,感觉跟镜像没关系,改完依然报错
而且 我正常是可以单独拉下依赖的 比如 npm install -g vue
看起来好像走了代理,配置了镜像源的话可以把代理关了试试
取消代理
npm config delete proxy
npm config delete https-proxy
清理缓存 npm install 还是如下报错
报错主要是第一次安装nodejs 按照教程下载安装,然后设置镜像,然后vcode里面执行npm install 就报上面的错。就很奇怪,然后网上搜 设置了 环境变量,改了文件读写权限啥的 都没太大改变。难顶
@当个胖子: 感觉还是走了代理,可以查看一下终端环境变量http_proxy
和https_proxy
,npm可能会自动读取这个值然后走代理
@当个胖子: 另外node目前稳定版是16.x.x, 建议用稳定版
@Laggage: 嗯嗯 就是因为试了都报一样的错 所以想着是不是版本的问题,就卸了换了试试看。感觉你上面说的有点道理 ,我先研究研究他的代理
换了低版本nodejs解决的,不过也是感觉也可以直接通过这个方法来解决,如果有需要可以去试试看,感觉挺有用的
– 当个胖子 2年前https://blog.csdn.net/weixin_43901865/article/details/118091905