【问题标题】:EBS Node.js 14: error TS5033: Could not write file: EACCES: permission deniedEBS Node.js 14:错误 TS5033:无法写入文件:EACCES:权限被拒绝
【发布时间】:2021-10-03 19:28:33
【问题描述】:

我最近使用 Node.js 14 创建了一个新的 EBS 环境,因为我的旧环境已被弃用。不幸的是,我遇到了以下错误:

Jul 27 22:34:53 ip-172-31-42-207 web: error TS5033: Could not write file '/var/app/current/build/server/validation.js.map': EACCES: permission denied, open '/var/app/current/build/server/validation.js.map'.
Jul 27 22:34:53 ip-172-31-42-207 web: error TS5033: Could not write file '/var/app/current/build/triggers/Triggers.js': EACCES: permission denied, open '/var/app/current/build/triggers/Triggers.js'.
Jul 27 22:34:53 ip-172-31-42-207 web: error TS5033: Could not write file '/var/app/current/build/triggers/Triggers.js.map': EACCES: permission denied, open '/var/app/current/build/triggers/Triggers.js.map'.
Jul 27 22:34:53 ip-172-31-42-207 web: npm ERR! code ELIFECYCLE
Jul 27 22:34:53 ip-172-31-42-207 web: npm ERR! errno 2
Jul 27 22:34:53 ip-172-31-42-207 web: npm ERR! ballotbox-server@0.0.1 start: `tsc && node build/index.js`
Jul 27 22:34:53 ip-172-31-42-207 web: npm ERR! Exit status 2
Jul 27 22:34:53 ip-172-31-42-207 web: npm ERR!
Jul 27 22:34:53 ip-172-31-42-207 web: npm ERR! Failed at the ballotbox-server@0.0.1 start script.
Jul 27 22:34:53 ip-172-31-42-207 web: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Jul 27 22:34:53 ip-172-31-42-207 web: npm ERR! A complete log of this run can be found in:
Jul 27 22:34:53 ip-172-31-42-207 web: npm ERR!     /home/webapp/.npm/_logs/2021-07-27T22_34_53_315Z-debug.log
Jul 27 22:34:53 ip-172-31-42-207 web: > ballotbox-server@0.0.1 start /var/app/current
Jul 27 22:34:53 ip-172-31-42-207 web: > tsc && node build/index.js

似乎TS由于权限无法生成我的JS文件。 我在旧环境中没有这个问题。此外,我已经将 unsafe-perm=true 添加到 .npmrc。

非常感谢任何想法,

谢谢!

【问题讨论】:

    标签: node.js typescript amazon-web-services npm amazon-elastic-beanstalk


    【解决方案1】:

    看来确实是权限问题。 EBS 默认处理 Javascript 而不是 Typescript,因此让它处理 tsc 命令可能很棘手。您有两种解决方案:

    • 在上传到 EBS 之前将代码转换为 JS。这意味着在本地运行 tsc 或使用 GitHub Actions 或 AWS CodeBuild 等 CI 管道
    • 在 EBS 运行 npm start 之前,使用 .ebextensions 文件在您的 EBS 环境将管理的 EC2 实例上全局安装 typescript。例如,您可以编写一个 bash 脚本,然后安装运行tsc 所需的所有依赖项。见这里:https://stackoverflow.com/a/43511790/17043933

    【讨论】:

      猜你喜欢
      • 2016-05-14
      • 2016-11-14
      • 1970-01-01
      • 1970-01-01
      • 2021-07-22
      • 2017-12-21
      • 2019-10-28
      • 2016-10-30
      • 2018-06-08
      相关资源
      最近更新 更多