Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Next.js-错误生成目录在EC2上不可写_Node.js_Amazon Ec2_Next.js - Fatal编程技术网

Node.js Next.js-错误生成目录在EC2上不可写

Node.js Next.js-错误生成目录在EC2上不可写,node.js,amazon-ec2,next.js,Node.js,Amazon Ec2,Next.js,这是我第一次在64位Amazon Linux/4.11.0的Elastic BeanStalk上运行带有自定义server.js的Next.js应用程序 在应用程序上创建后,环境和使用eb cli部署I在eb仪表板中收到一条警告环境健康状况已从降级过渡到严重 我将节点命令更改为配置为npm run deploy。没有什么变化 这是我的package.json "scripts": { "start": "pm2 start server.js -i max", "build":

这是我第一次在64位Amazon Linux/4.11.0的Elastic BeanStalk上运行带有自定义
server.js的Next.js应用程序

在应用程序上创建后,环境和使用eb cli部署I在eb仪表板中收到一条警告
环境健康状况已从降级过渡到严重

我将节点命令更改为配置为
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
>NODE_ENV=production next build&&pm2 start server.js-i max
>发生生成错误
错误:>生成目录不可写。https://err.sh/zeit/next.js/build-dir-not-writeable
在构建时(/var/app/current/node_modules/next/dist/build/index.js:1:6361)

在AWS支持下花了将近4个小时打电话后,他们的解决方案如下:

在项目的根目录中创建文件夹/文件:.ebextensions/00\u dir\u permission.config

commands:
  01_set_file_permissions:
    command: "chmod 777 -R /tmp"

当然这不太理想,但是由于某些原因,现在在EB中权限已经发生了变化,以至于在没有像这样调整权限的情况下,您无法启动构建。希望这种情况很快会改变。

我在本地遇到同样的错误,经过大约一个小时的故障排除,我意识到我的节点版本设置错误。似乎next 9.4不支持node的版本9。我更新到了版本12,它可以正常工作。

请尝试设置项目目录的权限-
sudo chmod 777-R/your_project_path
奇怪的是,今天我也发生了同样的事情?我和你一样运行4.11.0。你在karamon14找到解决办法了吗?