coding-memo/memo/nodenv.md
2025-03-24 09:17:35 +09:00

159 lines
3.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

AWS CDK ドキュメント : https://docs.aws.amazon.com/cdk/api/v2/docs/aws-construct-library.html
npm version : 10.2.3
nodenv version : 18.19.0
#nodenv導入
github:https://github.com/nodenv/nodenv
1. nodenvをクローンする
```
git clone https://github.com/nodenv/nodenv.git ~/.nodenv
```
インストール時間を短縮するためダイナミックバッシュでコンパイルする(失敗してもインストールできる)
```
cd ~/.nodenv && src/configure && make -C src
```
2. nodenvを`PATH`に追加する
```
echo 'export PATH="$HOME/.nodenv/bin:$PATH"' >> ~/.bashrc
```
現在のシェルにbash適用する
```
source ~/.bashrc
```
3. nodenvをshellにセットアップする
```
~/.nodenv/bin/nodenv init
```
表示されたコマンドで実行する
**プラットフォームによってコマンド違うので下記のコマンドを実行しない**
```
echo 'eval "$(nodenv init - bash)"' >> ~/.bashrc
source ~/.bashrc
```
4. nodenvインストール確認
```
curl -fsSL https://github.com/nodenv/nodenv-installer/raw/main/bin/nodenv-doctor | bash
```
下記の画面表示されたら完了
```
Checking for `nodenv' in PATH: /home/nik/.nodenv/bin/nodenv
Checking for nodenv shims in PATH: OK
Checking `nodenv install' support: not found
Unless you plan to add Node versions manually, you should install node-build.
Please refer to https://github.com/nodenv/node-build#installation
Counting installed Node versions: none
There aren't any Node versions installed under `/home/nik/.nodenv/versions'.
You can install Node versions like so: nodenv install <version>
Auditing installed plugins: OK
```
##node-buildインストールオプション
*nodenv install使用するに最適化されるプラグイン*
github: https://github.com/nodenv/node-build
```
mkdir -p "$(nodenv root)"/plugins
git clone https://github.com/nodenv/node-build.git "$(nodenv root)"/plugins/node-build
```
##node version 18.19.0インストール
```
nodenv install 18.19.0
nodenv global 18.19.0
```
nodeバージョン確認
```
node --version
npm --version
npx --version
```
# AWSプロファイル設定
```
aws configure sso --profile <プロファイル名>
```
コマンドからユーザー情報が保存できる
```
SSO session name (Recommended): its-pharma-core-dev
SSO start URL [None]: https://d-95675820f8.awsapps.com/start/#
SSO region [None]: ap-northeast-1
SSO registration scopes [sso:account:access]:
CLI default client Region [None]: ap-northeast-1
CLI default output format [None]: json
```
### AWSアカウント切り替え
```
export AWS_PROFILE=medaca
```
### アカウントSSO(シングルサインオン)再認証
```
aws sso login --profile <プロファイル名>
```
### Alias設定 (WSLでコマンド省略)
homeダイレクトリー変更
```
cd ~
```
.bashrcにaliasにしたいコマンド書く
```
vi .bashrc
```
例:
```
alias medaca='export AWS_PROFILE=medaca'
```
この場合は`export AWS_PROFILE=medaca`コマンドが`medaca`に省略できる
最後にsourceで現在のshellに読み込み
```
source ~/.bashrc
```
## 便利なサイト
AWSワークショップhttps://cdkworkshop.com/20-typescript/20-create-project/100-cdk-init.html
AWSサンプルCDKプロジェクトhttps://github.com/aws-samples/aws-cdk-examples/tree/main
AWS CDKベストプラクティスhttps://docs.aws.amazon.com/cdk/v2/guide/best-practices.html
https://docs.aws.amazon.com/pdfs/prescriptive-guidance/latest/best-practices-cdk-typescript-iac/best-practices-cdk-typescript-iac.pdf#introduction
### 命名規則:
camelCase変数、関数
PascalCaseクラス、インターフェイス
## 脆弱性ツール
cfn-naghttps://github.com/stelligent/cfn_nag
cdk-nag