由于较旧的节点和 npm 版本,无法在 appspec.yml 中运行应用程序启动脚本无法更新它们

如何解决由于较旧的节点和 npm 版本,无法在 appspec.yml 中运行应用程序启动脚本无法更新它们

我正在尝试使用 aws 中的代码管道在 EC2 实例上部署应用程序。我为此使用了 codedeploy。我能够成功地从 github 获取应用程序并使用 codebuild 构建它,但它在部署时失败并出现以下错误。我无法理解问题是什么。我已经尝试在 buildspec.yml 文件中更新 node 和 npm,但 appspec.yml 仍然无法提取 node/npm 的更新版本。我是 aws 的新手。有谁知道它从哪里提取这些版本以及如何覆盖它们?附上错误。我的 package.json。 appspec.yml。构建规范.yml。 application_start.sh 和 builspec_yml.sh。

这里是错误

[stderr]npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "server"
[stderr]npm ERR! node v6.17.1
[stderr]npm ERR! npm v3.10.10
[stderr]npm ERR! code ELIFECYCLE
[stderr]npm ERR! react-tmp@1.0.0 server: `node server.js`
[stderr]npm ERR! Exit status 1
[stderr]npm ERR!
[stderr]npm ERR! Failed at the react-tmp@1.0.0 server script 'node server.js'.
[stderr]npm ERR! Make sure you have the latest version of node.js and npm installed.
[stderr]npm ERR! If you do,this is most likely a problem with the react-tmp package,[stderr]npm ERR! not with npm itself.
[stderr]npm ERR! Tell the author that this fails on your system:
[stderr]npm ERR! node server.js
[stderr]npm ERR! You can get information on how to open an issue for this project with:
[stderr]npm ERR! npm bugs react-tmp
[stderr]npm ERR! Or if that isn't available,you can get their info via:
[stderr]npm ERR! npm owner ls react-tmp
[stderr]npm ERR! There is likely additional logging output above.
[stderr]npm WARN Local package.json exists,but node_modules missing,did you mean to install?
[stderr]npm ERR! Linux 4.14.209-160.339.amzn2.x86_64
[stderr]npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "server"
[stderr]npm ERR! node v6.17.1
[stderr]npm ERR! npm v3.10.10
[stderr]npm ERR! path npm-debug.log.4097552080
[stderr]npm ERR! code EACCES
[stderr]npm ERR! errno -13
[stderr]npm ERR! syscall open
[stderr]
[stderr]npm ERR! Error: EACCES: permission denied,open 'npm-debug.log.4097552080'
[stderr]npm ERR! at Error (native)
[stderr]npm ERR! { Error: EACCES: permission denied,open 'npm-debug.log.4097552080'
[stderr]npm ERR! at Error (native)
[stderr]npm ERR! errno: -13,[stderr]npm ERR! code: 'EACCES',[stderr]npm ERR! syscall: 'open',[stderr]npm ERR! path: 'npm-debug.log.4097552080' }
[stderr]npm ERR!
[stderr]npm ERR! Please try running this command again as root/Administrator.
[stderr]
[stderr]npm ERR! Please include the following file with any support request:
[stderr]npm ERR! /var/www/html/npm-debug.log

appspec.yml:

version: 0.0
os: linux
files:
  - source: /
    destination: /var/www/html/
hooks:
  ApplicationStart:
    - location: scripts/application_start.sh
      timeout: 300
      runas: ec2-user

application_start.sh:

#!/bin/bash

# Stop all servers and start the server as a daemon
cd /var/www/html/
forever stopall
nohup npm run server

buildspec.yml:

version: 0.2

phases:
  install:
    commands:
      - chmod +x scripts/buildspec_yml.sh
      - scripts/buildspec_yml.sh
  build:
    commands:
      - npm run start
artifacts:
  files:
    - '**/*'

scripts/builspec_yml.sh:

#!/bin/bash

nvm install 14.4.0
npm install -g npm@latest
npm i forever -g

感谢您对此进行调查

解决方法

与 aws 没有任何关系,查看您的 scripts/builspec_yml.sh 脚本,您似乎忘记指示 nvm 您希望 use 您安装的版本。试试...

#!/bin/bash

# install and use node version
nvm install 14.4.0
nvm use 14.4.0

# print node and npm version
node --version
npm --version

# upgrade npm and install forever
npm install -g npm@latest
npm install -g forever

如果您使用的是 nvm,我会建议您使用 .nvmrc 并在那里指定节点版本

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?