数字海洋应用部署错误:软件包和软件包锁不在同步运行NPM CI
我一直在尝试将我的应用程序部署到这里的数字海洋应用中,但是在过去的几天中,该应用程序遇到了一个致命的错误:
[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审核修复程序,但这也没有解决,
我在这里缺少什么?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当将Strapi v4.3.0部署到Digitalocean App Platform时,我早些时候也有同样的问题。修补后,我发现我的本地nodejs版本&amp;本地NPM版本与Digitalocean的使用不同。
我怀疑您的本地环境正在使用较早的NPM版本,而Digitalocean使用最新版本。
从NPM版本v8.4.1()NPM在运行
npm CI
命令时验证锁定文件。修复了我的情况
package.json
中设置我的引擎
与您的本地开发相同。例如:使用此集合,Digitalocean将使用节点版本lts V16.16.0
和NPM版本v8.11.0
lts v16.16.16.0
&amp;将npm更新为v8.11.0
node_modules
&amp;package_lock.json
从项目文件夹中npm缓存清洁 - force
npm install
再次重新下载the Package&amp;重新生成`package-lock.jsonnpm ci
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
engines
inpackage.json
same with your local development. For example: with this set, DigitalOcean will use Node versionLTS V16.16.0
and NPM versionv8.11.0
LTS V16.16.0
& update NPM tov8.11.0
node_modules
&package_lock.json
from the project foldernpm cache clean –force
npm install
again to re-download the package & re-generate `package-lock.jsonnpm ci
package-lock.json
to git