簡體   English   中英

EBS Node.js 14:錯誤 TS5033:無法寫入文件:EACCES:權限被拒絕

[英]EBS Node.js 14: error TS5033: Could not write file: EACCES: permission denied

我最近使用 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。

任何想法都非常感謝,

謝謝!

這似乎確實是一個權限問題。 EBS 默認處理 Javascript 而不是 Typescript,因此讓它處理 tsc 命令可能會很棘手。 您有兩種解決方案:

  • 在您上傳到 EBS 之前將您的代碼轉換為 JS。 這意味着在本地運行tsc或使用 CI 管道(如 GitHub Actions 或 AWS CodeBuild)
  • 在 EBS 運行npm start之前,使用 .ebextensions 文件在 EBS 環境將管理的 EC2 實例上全局安裝 typescript。 例如,您可以編寫一個 bash 腳本,然后安裝運行tsc所需的所有依賴項。 見這里: https : //stackoverflow.com/a/43511790/17043933

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM