Aad*_*gam 5 reactjs digital-ocean package.json next.js
我一直在尝试将我的应用程序部署到此处的数字海洋应用程序中,但在过去的几天里,该应用程序遇到了致命错误:
[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:Run Code Online (Sandbox Code Playgroud)
我无法找出问题发生的地方,我能够在本地完成构建。此问题仅在我部署到 Digital Ocean 时发生。
这是我的 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"
}
}Run Code Online (Sandbox Code Playgroud)
我尝试过的可能解决方案
我在这里缺少什么?
我之前在将 Strapi v4.3.0 部署到 DigitalOcean 应用程序平台时遇到了同样的问题。经过一番修改,我发现我本地的 NodeJS 版本和本地 NPM 版本与 DigitalOcean 使用的不同。
\n我怀疑您的本地环境使用的是较早的 npm 版本,而 digitalocean 使用的是最新版本。
\n从 NPM 版本 v8.4.1 ( https://github.com/npm/cli/pull/4369 ) 开始,npm 在运行命令时验证锁定文件npm ci。
修复我的情况
\nengines保持package.json一致。例如:使用此设置,DigitalOcean 将使用 Node 版本LTS V16.16.0和 NPM 版本v8.11.0 "engines": {\n "node": ">=12.x.x <=16.x.x",\n "npm": ">=6.0.0"\n },\nRun Code Online (Sandbox Code Playgroud)\nLTS V16.16.0& 将 NPM 更新为v8.11.0node_modules&package_lock.jsonnpm cache clean \xe2\x80\x93forcenpm install重新下载包并重新生成 `package-lock.jsonnpm cipackage-lock.jsongit| 归档时间: |
|
| 查看次数: |
9054 次 |
| 最近记录: |