首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >package-lock.json --如何修复版本错误

package-lock.json --如何修复版本错误
EN

Stack Overflow用户
提问于 2021-01-08 17:59:46
回答 1查看 2.5K关注 0票数 1

我正在设置一个GitHub操作来自动链接和测试每个提交。不幸的是,当npm安装依赖项时,操作总是失败。

简而言之,我认为这个包有点混乱--lock.json,我需要以某种方式重新生成它。有什么想法吗?

误差

代码语言:javascript
复制
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/fsevents/-/fsevents-2.2.3.tgz
npm ERR! 404 
npm ERR! 404  'fsevents@2.2.1' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2021-01-08T07_29_59_535Z-debug.log

我相信这是包的这一部分的结果-lock.json

代码语言:javascript
复制
"fsevents": {
    "version": "2.2.1",
    "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.2.3.tgz",
    "integrity": "sha512-bTLYHSeC0UH/EFXS9KqWnXuOl/wHK5Z/d+ghd5AsFMYN7wIGkUCOJyzy88+wJKkZPGON8u4Z9f6U4FdgURE9qA==",
    "dev": true,
    "optional": true
}

注意URL与版本号是如何不同的。Fsevents从来没有2.2.3,只有2.2.2。

Fsevents不是该项目的直接依赖项(也就是说,它不在package.json中)。

调试步骤

我试过:

  • npm update
  • npm audit fix
  • 删除包-lock.json,然后是npm install
  • npm install --package-lock
  • 手工编辑包-lock.json,但它只是在npm install之后恢复
  • 在我的电脑(macOS Big,Intel)上,我做了rm -rf node_modules && npm install,但是我在安装或运行测试时有任何问题。
  • 在我的电脑上,我尝试了npm ci,就像操作一样,没有错误或问题。

GitHub动作

如果这会产生影响,下面是GitHub操作:

代码语言:javascript
复制
name: Continuous integration

on: [push]

jobs:
  test-push:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 14
      - run: npm ci
      - run: npm run lint
      - run: npm run test

错误发生在npm ci步骤上。

更新:我还在macOS上用runs-on: macos-latest尝试了Github。同样的错误。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-01-10 02:00:48

结果,我需要同时删除node_modules和package-lock.json。只做两个人中的一个就没用了。

代码语言:javascript
复制
rm -rm node_modules
rm package-lock.json
npm i
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65634090

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档