npm install下载依赖时为什么一直报错401?

最近在用npm install下载项目依赖时,总是提示这个错误npm install下载依赖时为什么一直报错401?但是我用npm login登录了npm之后安装依赖依然会报此错误,这是什么情况呢
安装过程:

npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained

npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintainednpm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated

npm WARN deprecated har-validator@5.1.5: this library is no longer supported

npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.

npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.

npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated

npm WARN deprecated fingerprintjs2@2.1.4: Package has been renamed to @fingerprintjs/fingerprintjs. Install @fingerprintjs/fingerprintjs to get updates.

npm WARN deprecated html-webpack-plugin@3.2.0: 3.x is no longer supported

npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'

npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.

npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.

npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142

npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained

npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'

npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.

npm ERR! code E401

npm ERR! Unable to authenticate, your authentication token seems to be invalid.

npm ERR! To correct this please trying logging in again with:

npm ERR! npm login

npm ERR! A complete log of this run can be found in:

依赖包:
npm install下载依赖时为什么一直报错401?


回答:

方案1:

  1. 看一下当前node的版本, 过高的话换12.x.x的试试 - 用nvm node版本管理去切
  2. 删掉当前的node_module, 同步删除 package-lock.json
  3. 执行安装试试

方案2:

  1. 删掉当前的node_module, 同步删除 package-lock.json
  2. 安装yarn
  3. 用yarn 去 install

方案3:

  1. npm config list -> 查看当前镜像源
  2. npm config set registry https://registry.npm.taobao.org -> 设置镜像
  3. 执行安装


回答:

1:有没有package-lock.json文件 ,删了package-lock.json文件,再npm i 试试,参看下这个

以上是 npm install下载依赖时为什么一直报错401? 的全部内容, 来源链接: utcz.com/p/936752.html

回到顶部