Rag*_*agu 2 amazon-web-services aws-codepipeline
I am new to create a pipeline in aws. I want to create a ci-cd pipeline for my nuxt project. I create a yml file in which I want to install nvm and then install node version 12.18.3
The problem is I am getting the nvm not found error.
Can you please check and let me know if there is any error in my yml file:
version: 0.2
phases:
install:
commands:
- echo Installing nvm...
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
- export NVM_DIR="$HOME/.nvm"
- '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"'
- '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"'
pre_build:
commands:
#install dependencies
- echo Installing node...
- nvm install 12.18.3
- echo Installing npm...
- npm install
build:
commands:
#build
- echo building...
- npm run generate
artifacts:
files:
- '**/*'
base-directory: dist
cache:
paths:
- node_modules/**/*
Run Code Online (Sandbox Code Playgroud)
Thank you.
由于某种原因,它无法识别下一行中的 nvm 。我没有机会进一步调查它。以下配置有效。这个想法是在同一行中设置 nvm 配置和安装节点。
version: 0.2
phases:
install:
commands:
- echo Installing nvm...
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
- export NVM_DIR="$HOME/.nvm"
- '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"'
- '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"'
pre_build:
commands:
#install dependencies
- . "$NVM_DIR/nvm.sh" && nvm install 12.18.3 && echo "node installed by arun"
- echo Installing node...
#- nvm install 12.18.3
- echo Installing npm...
- npm install
build:
commands:
#build
- echo building...
- npm run generate
cache:
paths:
- node_modules/**/*
Run Code Online (Sandbox Code Playgroud)
为了对 buildspec.yaml 进行故障排除,您可以在本地运行构建。以下是如何在本地运行构建规范。
您实际上不需要使用 nvm 在 AWS CodeBuild 上安装特定的 node.js 版本。
您可以使用运行时版本选项来安装某个版本,但您对此没有太多控制权。
phases:
install:
runtime-versions:
nodejs: 12.x
Run Code Online (Sandbox Code Playgroud)
但是AWS标准5镜像预装了n(没有检查4,但它也应该在那里),所以你可以像这样使用它:
phases:
install:
commands:
- n 12.18.3
Run Code Online (Sandbox Code Playgroud)
它会安装与 nvm 相同的版本。
| 归档时间: |
|
| 查看次数: |
3240 次 |
| 最近记录: |