数字海洋应用部署错误:软件包和软件包锁不在同步运行NPM CI

发布于 2025-02-06 19:14:30 字数 9606 浏览 4 评论 0 原文

我一直在尝试将我的应用程序部署到这里的数字海洋应用中,但是在过去的几天中,该应用程序遇到了一个致命的错误:

[2022-06-13 07:11:31] npm ERR! `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
[2022-06-13 07:11:31] npm ERR! 
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @ampproject/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: [email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: [email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: [email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @jridgewell/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @jridgewell/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @jridgewell/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: [email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: [email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: [email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: [email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @jridgewell/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @jridgewell/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @jridgewell/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: [email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: [email protected] from lock file
[2022-06-13 07:11:31] npm ERR! 
[2022-06-13 07:11:31] npm ERR! Clean install a project
[2022-06-13 07:11:31] npm ERR! 
[2022-06-13 07:11:31] npm ERR! Usage:
[2022-06-13 07:11:31] npm ERR! npm ci
[2022-06-13 07:11:31] npm ERR! 
[2022-06-13 07:11:31] npm ERR! Options:
[2022-06-13 07:11:31] npm ERR! [--no-audit] [--foreground-scripts] [--ignore-scripts]
[2022-06-13 07:11:31] npm ERR! [--script-shell <script-shell>]
[2022-06-13 07:11:31] npm ERR! 
[2022-06-13 07:11:31] npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
[2022-06-13 07:11:31] npm ERR! 
[2022-06-13 07:11:31] npm ERR! Run "npm help ci" for more info
[2022-06-13 07:11:31] 
[2022-06-13 07:11:31] npm ERR! A complete log of this run can be found in:

我无法找出问题发生在哪里,我能够在本地完成构建。这个问题仅在我部署到数字海洋时发生。

这是我的包裹。

{
  "name": "sample-app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build && next-sitemap --config next-sitemap.config.js",
    "start": "next start",
    "analyze": "ANALYZE=true next build"
  },
  "dependencies": {
    "@emotion/cache": "^11.7.1",
    "@emotion/react": "^11.9.0",
    "@emotion/server": "^11.4.0",
    "@emotion/styled": "^11.8.1",
    "@mui/material": "^5.8.3",
    "@next/bundle-analyzer": "^12.1.6",
    "@parse/react-ssr": "^0.0.1-alpha.18",
    "appbase-js": "^5.0.0",
    "axios": "^0.27.2",
    "body-scroll-lock": "^4.0.0-beta.0",
    "cacheable-response": "^2.7.10",
    "child_process": "^1.0.2",
    "firebase": "^9.8.3",
    "framer-motion": "^6.3.11",
    "heic2any": "^0.0.3",
    "isomorphic-dompurify": "^0.19.0",
    "javascript-time-ago": "^2.5.4",
    "js-cookie": "^3.0.1",
    "memory-cache": "^0.2.0",
    "moment": "^2.29.3",
    "next": "^12.0.7",
    "next-redux-wrapper": "^7.0.5",
    "next-sitemap": "^3.0.5",
    "parse": "^3.4.2",
    "react": "^17.0.2",
    "react-confetti": "^6.1.0",
    "react-contenteditable": "^3.3.6",
    "react-device-detect": "^2.2.2",
    "react-dom": "^17.0.2",
    "react-image-file-resizer": "^0.4.8",
    "react-infinite-scroll-component": "^6.1.0",
    "react-lazy-load-image-component": "^1.5.4",
    "react-masonry-css": "^1.0.16",
    "react-redux": "^8.0.2",
    "react-textarea-autosize": "^8.3.4",
    "react-time-ago": "^7.2.1",
    "react-toggle": "^4.1.2",
    "react-tweet-embed": "^2.0.0",
    "recharts": "^2.1.10",
    "redux": "^4.2.0",
    "redux-devtools-extension": "^2.13.9",
    "redux-thunk": "^2.4.1",
    "sass": "^1.52.3",
    "sharp": "^0.30.6",
    "swr": "^1.3.0",
    "use-long-press": "^2.0.2",
    "validator": "^13.7.0"
  }
}

我尝试过的可能解决方案

  • 我尝试删除package-lock.json文件并创建了一个新版本,但没有解决它。
  • 我尝试运行NPM审核修复程序,但这也没有解决,

我在这里缺少什么?

I've been trying to deploy my app into a digital ocean app here, but for the past days, the app hits a fatal error saying:

[2022-06-13 07:11:31] npm ERR! `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
[2022-06-13 07:11:31] npm ERR! 
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @ampproject/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: [email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: [email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: [email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @jridgewell/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @jridgewell/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @jridgewell/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: [email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: [email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: [email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: [email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @jridgewell/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @jridgewell/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @jridgewell/[email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: [email protected] from lock file
[2022-06-13 07:11:31] npm ERR! Missing: [email protected] from lock file
[2022-06-13 07:11:31] npm ERR! 
[2022-06-13 07:11:31] npm ERR! Clean install a project
[2022-06-13 07:11:31] npm ERR! 
[2022-06-13 07:11:31] npm ERR! Usage:
[2022-06-13 07:11:31] npm ERR! npm ci
[2022-06-13 07:11:31] npm ERR! 
[2022-06-13 07:11:31] npm ERR! Options:
[2022-06-13 07:11:31] npm ERR! [--no-audit] [--foreground-scripts] [--ignore-scripts]
[2022-06-13 07:11:31] npm ERR! [--script-shell <script-shell>]
[2022-06-13 07:11:31] npm ERR! 
[2022-06-13 07:11:31] npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
[2022-06-13 07:11:31] npm ERR! 
[2022-06-13 07:11:31] npm ERR! Run "npm help ci" for more info
[2022-06-13 07:11:31] 
[2022-06-13 07:11:31] npm ERR! A complete log of this run can be found in:

I am not able to find out where the issue is happening, I am able to complete a build locally. This issue only happens while I deploy to Digital Ocean.

Here is my package.json:

{
  "name": "sample-app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build && next-sitemap --config next-sitemap.config.js",
    "start": "next start",
    "analyze": "ANALYZE=true next build"
  },
  "dependencies": {
    "@emotion/cache": "^11.7.1",
    "@emotion/react": "^11.9.0",
    "@emotion/server": "^11.4.0",
    "@emotion/styled": "^11.8.1",
    "@mui/material": "^5.8.3",
    "@next/bundle-analyzer": "^12.1.6",
    "@parse/react-ssr": "^0.0.1-alpha.18",
    "appbase-js": "^5.0.0",
    "axios": "^0.27.2",
    "body-scroll-lock": "^4.0.0-beta.0",
    "cacheable-response": "^2.7.10",
    "child_process": "^1.0.2",
    "firebase": "^9.8.3",
    "framer-motion": "^6.3.11",
    "heic2any": "^0.0.3",
    "isomorphic-dompurify": "^0.19.0",
    "javascript-time-ago": "^2.5.4",
    "js-cookie": "^3.0.1",
    "memory-cache": "^0.2.0",
    "moment": "^2.29.3",
    "next": "^12.0.7",
    "next-redux-wrapper": "^7.0.5",
    "next-sitemap": "^3.0.5",
    "parse": "^3.4.2",
    "react": "^17.0.2",
    "react-confetti": "^6.1.0",
    "react-contenteditable": "^3.3.6",
    "react-device-detect": "^2.2.2",
    "react-dom": "^17.0.2",
    "react-image-file-resizer": "^0.4.8",
    "react-infinite-scroll-component": "^6.1.0",
    "react-lazy-load-image-component": "^1.5.4",
    "react-masonry-css": "^1.0.16",
    "react-redux": "^8.0.2",
    "react-textarea-autosize": "^8.3.4",
    "react-time-ago": "^7.2.1",
    "react-toggle": "^4.1.2",
    "react-tweet-embed": "^2.0.0",
    "recharts": "^2.1.10",
    "redux": "^4.2.0",
    "redux-devtools-extension": "^2.13.9",
    "redux-thunk": "^2.4.1",
    "sass": "^1.52.3",
    "sharp": "^0.30.6",
    "swr": "^1.3.0",
    "use-long-press": "^2.0.2",
    "validator": "^13.7.0"
  }
}

Possible Solutions I have tried

  • I tried deleting my package-lock.json file and created a fresh version, but it didn't solve it.
  • I tried running npm audit fix but that didn't work out too

What am I missing here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我很OK 2025-02-13 19:14:30

当将Strapi v4.3.0部署到Digitalocean App Platform时,我早些时候也有同样的问题。修补后,我发现我的本地nodejs版本&amp;本地NPM版本与Digitalocean的使用不同。

我怀疑您的本地环境正在使用较早的NPM版本,而Digitalocean使用最新版本。

从NPM版本v8.4.1()NPM在运行 npm CI 命令时验证锁定文件。

修复了我的情况

  1. package.json 中设置我的引擎与您的本地开发相同。例如:使用此集合,Digitalocean将使用节点版本 lts V16.16.0 和NPM版本 v8.11.0
  "engines": {
    "node": ">=12.x.x <=16.x.x",
    "npm": ">=6.0.0"
  },
  1. 将Nodejs更新为 lts v16.16.16.0 &amp;将npm更新为 v8.11.0
  2. delete node_modules &amp; package_lock.json 从项目文件夹中
  3. 清洁NPM缓存, npm缓存清洁 - force
  4. do npm install 再次重新下载the Package&amp;重新生成`package-lock.json
  5. 验证其是否通过运行 npm ci
  6. 将新 package> package> package> package> package-lock.json 验证

I have the same problem earlier when deploying Strapi v4.3.0 to DigitalOcean app platform. After some tinkering, I found out that my local NodeJS version & local NPM version is different from what DigitalOcean uses.

I suspect that your local environment is using an earlier npm version while digitalocean using the latest version.

Starting from NPM version v8.4.1 ( https://github.com/npm/cli/pull/4369 ) npm validates the lock file when running the npm ci command.

Fix for my case

  1. set my engines in package.json same with your local development. For example: with this set, DigitalOcean will use Node version LTS V16.16.0 and NPM version v8.11.0
  "engines": {
    "node": ">=12.x.x <=16.x.x",
    "npm": ">=6.0.0"
  },
  1. update NodeJs to LTS V16.16.0 & update NPM to v8.11.0
  2. delete node_modules & package_lock.json from the project folder
  3. clean npm cache with npm cache clean –force
  4. do npm install again to re-download the package & re-generate `package-lock.json
  5. verify if its working by running npm ci
  6. push new package-lock.json to git
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文