如何在不触发更新检查的情况下运行 npm 脚本

时间:2021-04-19 10:12:03

标签: npm

是否有命令行选项可以在不触发更新检查的情况下使用 npm run-script ...

我问是因为我使用 concurrently 来运行两个脚本。通常,但并非总是如此,我会收到“npm 更新检查失败”错误消息,并且(我相信)这是因为节点的两次调用都在尝试同时访问 .config 存储。

package.json 的相关部分

  "scripts": {
    "build": "webpack",
    "start": "concurrently \"npm:start-browser\" \"npm:start-server\"",
    "start-browser": "node start-browser.js",
    "start-server": "node index.mjs",
  },

我用 npm start 运行它。

我在 Windows 10 上使用节点 14.15.1 和 npm 6.14.8。

错误的全文是

┌────────────────────────────────────────────────────────────┐
│                  npm update check failed                   │
│            Try running with sudo or get access             │
│            to the local update config store via            │
│ sudo chown -R $USER:$(id -gn $USER) C:\Users\pedro\.config │
└────────────────────────────────────────────────────────────┘

注意:我在运行其他 npm 脚本时从未看到此错误,只有带有 concurrently 的脚本,这就是为什么我认为这与对 .config 的并发访问有关

(编辑)这是一个最小的 package.json,它将显示错误(对我来说,大约 25% 的时间)

{
  "name": "coco",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "concurrently npm:start-1 npm:start-1",
    "start-1":"node index.js"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "concurrently": "^6.0.2"
  }
}

和 index.js 是

console.log("Hello World");

注意:如果我在 Windows 管理员 Power Shell 中运行,我仍然会收到错误消息

0 个答案:

没有答案
相关问题