首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >数字海洋应用程序部署错误:包和包锁不同步运行npm ci

数字海洋应用程序部署错误:包和包锁不同步运行npm ci
EN

Stack Overflow用户
提问于 2022-06-13 07:20:03
回答 1查看 1.9K关注 0票数 2

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

代码语言:javascript
复制
[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/core@7.18.5 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @ampproject/remapping@2.2.0 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/generator@7.18.2 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/helper-compilation-targets@7.18.2 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/helper-module-transforms@7.18.0 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/helpers@7.18.2 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/parser@7.18.5 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/template@7.16.7 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/traverse@7.18.5 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: gensync@1.0.0-beta.2 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: json5@2.2.1 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: semver@6.3.0 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @jridgewell/gen-mapping@0.1.1 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @jridgewell/trace-mapping@0.3.13 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @jridgewell/gen-mapping@0.3.1 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: jsesc@2.5.2 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/compat-data@7.18.5 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/helper-validator-option@7.16.7 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: browserslist@4.20.4 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: semver@6.3.0 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/helper-environment-visitor@7.18.2 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/helper-simple-access@7.18.2 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/helper-split-export-declaration@7.16.7 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/helper-function-name@7.17.9 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @babel/helper-hoist-variables@7.16.7 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: globals@11.12.0 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @jridgewell/set-array@1.1.1 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @jridgewell/sourcemap-codec@1.4.13 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: @jridgewell/resolve-uri@3.0.7 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: electron-to-chromium@1.4.152 from lock file
[2022-06-13 07:11:31] npm ERR! Missing: node-releases@2.0.5 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:

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

这是我的package.json:

代码语言:javascript
复制
{
  "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"
  }
}

可能的解决方案我尝试过

我尝试删除我的包-lock.json文件,并创建了一个新版本,但它没有解决这个问题。

我在这里错过了什么?

EN

回答 1

Stack Overflow用户

发布于 2022-07-27 21:36:45

在前面将Strapiv4.3.0部署到DigitalOcean应用程序平台时,我也遇到了同样的问题。经过一些修改后,我发现我的本地NodeJS版本&本地NPM版本与DigitalOcean使用的不同。

我怀疑您的本地环境使用的是较早的npm版本,而数字海洋使用的是最新版本。

从npmVersionv8.4.1( https://github.com/npm/cli/pull/4369 )开始,NPM在运行npm ci命令时验证锁文件。

修正了我的案子

  1. 将我的engines设置为package.json,与您的本地开发相同。例如:使用此集合,DigitalOcean将使用Node版本LTS V16.16.0和NPM版本LTS V16.16.0

代码语言:javascript
复制
  "engines": {
    "node": ">=12.x.x <=16.x.x",
    "npm": ">=6.0.0"
  },

v8.11.0

  • delete

  • 更新NodeJs到LTS V16.16.0,并将npm更新为npm cache clean –force

  • do npm install的项目文件夹

  • 清理NPM缓存,以重新下载包并重新生成`package-lock.json

  • verify,如果它通过运行npm ci

  • push newpackage-lock.json到gitH 233G 234
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72599027

复制
相关文章

相似问题

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