3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

UbuntuでAWS CDK環境構築ではまった事。

Posted at

Ubuntu 20.04
Node.js 16.13

WindowsでAWS CDKを構築したが、どうもCDKが上手くいかない。
情報がWindowsよりもMac Linuxが多いので、Ubuntuで再度構築。

nodejsのインストールでハマってしまったのでメモ。
npm install -g aws-cdkを実行したらエラーが・・

npm notice 
npm notice New minor version of npm available! 8.1.2 -> 8.3.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.3.0
npm notice Run npm install -g npm@8.3.0 to update!
npm notice 
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/aws-cdk
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/aws-cdk'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/aws-cdk'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules/aws-cdk'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/saito/.npm/_logs/2021-12-14T21_04_20_425Z-debug.log
```
そこで、調べたら、2つの有力な情報を発見しました。
[npmでpermission deniedになった時の対処法[mac]](https://qiita.com/okohs/items/ced3c3de30af1035242d)


この情報を参考に
 npm install -g npmを実行しましたが、エラー
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/npm
npm ERR! dest /usr/local/lib/node_modules/.npm-i9nnxROI
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'
npm ERR!  [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'] {
npm ERR!   errno: -13,
...

【備忘録】npm -g install に失敗する
この情報を参考に

s:~$ mkdir ~/.npm-global
s:~$ npm config set prefix '~/.npm-global'
s:~$ echo ' export PATH=~/.npm-global/bin:$PATH' >> ~/.bash_profile
s:~$ source ~/.bash_profile
s:~$ npm install -g npm

npm install -g npmを再度実行したら正常に実行されました。

AWS CDKインストール

sudo npm install -g aws-cdk

無事、正常にインストールできました。

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?