You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行npm create vite@latest/npm install时出现EACCES连接错误求助

解决npm create vite@latest出现EACCES连接错误

执行npm create vite@latest时遇到如下错误:

npm ERR! code EACCES
npm ERR! syscall connect
npm ERR! errno EACCES
npm ERR! FetchError: request to https://registry.npmjs.org/create-vite failed, reason: connect EACCES 2606:4700::6810:1623:443
npm ERR!     at ClientRequest.<anonymous> (/usr/lib/node_modules/npm/node_modules/minipass-fetch/lib/index.js:130:14)
npm ERR!     at ClientRequest.emit (node:events:512:28)
npm ERR!     at TLSSocket.socketErrorListener (node:_http_client:496:9)
npm ERR!     at TLSSocket.emit (node:events:524:35)
npm ERR!     at emitErrorNT (node:internal/streams/destroy:151:8)
npm ERR!     at emitErrorCloseNT (node:internal/streams/destroy:116:3)
npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
npm ERR!  FetchError: request to https://registry.npmjs.org/create-vite failed, reason: connect EACCES 2606:4700::6810:1623:443
npm ERR!     at ClientRequest.<anonymous> (/usr/lib/node_modules/npm/node_modules/minipass-fetch/lib/index.js:130:14)
npm ERR!     at ClientRequest.emit (node:events:512:28)
npm ERR!     at TLSSocket.socketErrorListener (node:_http_client:496:9)
npm ERR!     at TLSSocket.emit (node:events:524:35)
npm ERR!     at emitErrorNT (node:internal/streams/destroy:151:8)
npm ERR!     at emitErrorCloseNT (node:internal/streams/destroy:116:3)
npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
npm ERR!   code: 'EACCES',
npm ERR!   errno: 'EACCES',
npm ERR!   syscall: 'connect',
npm ERR!   address: '2606:4700::6810:1623',
npm ERR!   port: 443,
npm ERR!   type: 'system'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/wenanoshe/.npm/_logs/2023-02-22T20_27_32_249Z-debug-0.log

已尝试重装npm、以管理员身份运行命令,问题仍存在。

解决方案

  • 检查IPv6与防火墙设置
    错误中显示的是IPv6地址连接失败,可临时禁用IPv6测试:

    sysctl -w net.ipv6.conf.all.disable_ipv6=1
    

    同时确认系统防火墙/安全软件未拦截npm对443端口的访问。

  • 切换至国内npm镜像
    替换官方registry为国内镜像,避免网络访问问题:

    npm config set registry https://registry.npmmirror.com/
    

    之后重新执行npm create vite@latest。

  • 修复npm全局目录权限
    重置npm全局目录的所有者,避免权限冲突:

    sudo chown -R $USER:$GROUP ~/.npm
    

    或者配置自定义全局目录,彻底避开系统权限问题:

    mkdir -p ~/.npm-global
    npm config set prefix '~/.npm-global'
    echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.profile
    source ~/.profile
    
  • 直接指定registry执行npx命令
    跳过npm配置,临时使用国内镜像执行创建命令:

    npx --registry=https://registry.npmmirror.com create-vite@latest
    

内容的提问来源于stack exchange,提问作者Wenanoshe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 19:27:22