我正在嘗試使用 heroku CLI 將 Next,js 應用程式部署到 heroku。當我運行時,我遇到了以下問題git push heroku master。這是我當前設定中的 package.json 檔案。請幫忙。我已經搜索了這個問題,但我找不到與它相關的任何內容。我可以在本地機器上構建 next.js 應用程式,但不能在 heroku 中部署。
包.json
{
"name": "XXXX-ecommerce",
"version": "0.1.0",
"engines": {
"node": "18.x",
"npm": "7.x"
},
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"heroku-postbuild": "npm run build",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"@apollo/client": "^3.7.0",
"@nacelle/react-yotpo": "^8.0.0",
"axios": "^1.1.3",
"cookie": "^0.5.0",
"cookie-cutter": "^0.2.0",
"graphql": "^16.6.0",
"lodash": "^4.17.21",
"lodash.filter": "^4.6.0",
"lodash.uniqby": "^4.7.0",
"next": "12.3.1",
"react": "18.2.0",
"react-collapsible": "^2.10.0",
"react-dom": "18.2.0",
"react-rating": "^2.0.5",
"swiper": "^8.4.2"
},
"devDependencies": {
"eslint": "8.24.0",
"eslint-config-next": "12.3.1"
}
}
Heroko 構建日志:
info - Creating an optimized production build...
Failed to compile.
./components/card.js
Module not found: Can't resolve 'lodash.uniqBy' in '/tmp/build_54073365/components'
Import trace for requested module:
./components/card.js
./components/productSlider.js
./pages/products/[id].js
Module not found: Can't resolve 'lodash.uniqBy' in
'/tmp/build_54073365/pages/products'
> Build failed because of webpack errors
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
uj5u.com熱心網友回復:
包名是lodash.uniqby(全小寫)。檢查您的匯入,看起來您uniqBy的一個組件中有(大寫字母 B)。這可能在本地作業,因為 macOS 和 Windows 具有不區分大小寫的檔案系統,所以它可以在本地作業,但在部署到運行 Linux 的機器上時不能作業,比如在 Heroku 上。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/528163.html
