[英]Next.js - ERROR Build directory is not writeable on EC2
我第一次運行我的 Next.js 應用程序,在 Elastic BeanStalk 上使用自定義server.js
和64bit Amazon Linux/4.11.0
。
在使用 eb-cli 創建應用程序、環境和部署后,我在 EB 儀表板中收到警告Environment health has transitioned from Degraded to Severe
。
我將Node 命令更改為配置為npm run deploy
。 沒有改變。
這是我的package.json
。
"scripts": {
"start": "pm2 start server.js -i max",
"build": "next build",
"dev": "nodemon --exec babel-node server.js",
"start-next": "next start",
"deploy": "NODE_ENV=production next build && pm2 start server.js -i max",
"test": "echo \"Error: no test specified\" && exit 1"
},
我使用eb ssh
連接到 eb 實例,在找到項目目錄后,我嘗試執行npm run build
,但發生錯誤。
> NODE_ENV=production next build && pm2 start server.js -i max
> Build error occurred
Error: > Build directory is not writeable. https://err.sh/zeit/next.js/build-dir-not-writeable
at build (/var/app/current/node_modules/next/dist/build/index.js:1:6361)
at <anonymous>
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webreader-client@1.0.0 deploy: `NODE_ENV=production next build && pm2 start server.js -i max`
npm ERR! Exit status 1
我用sudo
創建了一個.next
目錄,但仍然出現錯誤。
文檔: https://github.com/zeit/next.js/blob/master/errors/build-dir-not-writeable.md
我在本地遇到了同樣的錯誤,經過大約一個小時的故障排除后,我意識到我的節點版本設置錯誤。 似乎下一個 9.4 不支持節點的版本 9。 我更新到第 12 版,它的工作沒有問題。
在與 AWS Support 通話近 4 小時后,他們的解決方案如下:
在項目的根目錄中創建一個文件夾/文件:.ebextensions/00_dir_permission.config
commands:
01_set_file_permissions:
command: "chmod 777 -R /tmp"
當然,這不太理想,但由於某種原因,現在 EB 中的權限已更改,以至於您無法在不調整此類權限的情況下啟動構建。 希望這種情況很快改變。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.