获取:npm WARN 使用 --force 建议的保护已禁用

Pej*_*yri 24 node.js npm vue.js package.json nuxt.js

我有一个在 Node 12 中开发的旧 Nuxt.js 包,我现在想将它与 Node 16(最新稳定版)一起使用,但是当我尝试安装我的包时,npm install我收到了版本差异错误。

但我知道这些软件包是最新的。因此,我试图强制清除我的 npm 缓存,sudo npm cache clean -f但出现此错误:

npm 使用 --force 发出警告 禁用建议的保护。

环境是ubuntu 20.04,这是我的package.json文件:

{
  "name": "frontend",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate"
  },
  "dependencies": {
    "@nuxtjs/auth": "^4.9.1",
    "@nuxtjs/axios": "^5.13.6",
    "@nuxtjs/dotenv": "^1.4.1",
    "@nuxtjs/google-adsense": "^1.4.0",
    "@nuxtjs/gtm": "^2.4.0",
    "@nuxtjs/router": "^1.6.1",
    "better-vue-input-tag": "^1.1.0",
    "bootstrap": "^5.1.3",
    "bootstrap-vue": "^2.21.2",
    "core-js": "^3.19.2",
    "eslint": "^8.3.0",
    "jquery": "^3.6.0",
    "laravel-vue-pagination": "^2.3.1",
    "node-sass": "^6.0.1",
    "nuxt": "^2.15.8",
    "popper.js": "^1.16.1",
    "sass-loader": "^12.3.0",
    "vform": "^2.1.2",
    "vue-autosuggest": "^2.2.0",
    "vue-gtag": "^1.16.1",
    "vue-infinite-loading": "^2.4.5",
    "vue2-google-maps-withscopedautocomp": "^0.12.1"
  },
  "devDependencies": {
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-prettier": "^4.0.0",
    "ip": "^1.1.5",
    "prettier": "^2.5.0"
  }
}
Run Code Online (Sandbox Code Playgroud)

如何使用强制标志而不出现错误?

编辑:

我因版本差异而收到的错误: 在此输入图像描述

小智 67

所以我遇到了和你一样的问题,我认为缓存不起作用,但实际上它起作用了,这只是一条警告消息,尝试这个命令npm cache verify来验证缓存是否起作用,如果它起作用,你的问题是与缓存无关,但问题可能出在您的节点版本上。

PS C:\code>  npm cache clean --force
npm WARN using --force Recommended protections disabled.
PS C:\code> npm cache verify
Cache verified and compressed (~\AppData\Local\npm-cache\_cacache)
Content verified: 0 (0 bytes)
Index entries: 0
Finished in 0.008s
PS C:\code>
Run Code Online (Sandbox Code Playgroud)