Check current npm version
❯ which npm
/Users/loll/.nvm/versions/node/v14.15.1/bin/npm
Update to latest LTS Nodejs
❯ nvm install 14.17.2
Downloading and installing node v14.17.2...
Downloading https://nodejs.org/dist/v14.17.2/node-v14.17.2-darwin-x64.tar.xz...
####################################################################### 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v14.17.2 (npm v6.14.13)
But, command that I installed globally not found
❯ which cdk
cdk not found
Solution, with reinstall packages command
❯ nvm install 14.17.2 --reinstall-packages-from=14.15.1 --latest-npm
#####
v14.17.2 is already installed.
Now using node v14.17.2 (npm v6.14.13)
VERSION=''
Reinstalling global packages from v14.15.1...
/Users/loll/.nvm/versions/node/v14.17.2/bin/wrangler -> /Users/loll/.nvm/versions/node/v14.17.2/lib/node_modules/@cloudflare/wrangler/run-wrangler.js
/Users/loll/.nvm/versions/node/v14.17.2/bin/cdk -> /Users/loll/.nvm/versions/node/v14.17.2/lib/node_modules/aws-cdk/bin/cdk
/Users/loll/.nvm/versions/node/v14.17.2/bin/cdk-dasm -> /Users/loll/.nvm/versions/node/v14.17.2/lib/node_modules/cdk-dasm/bin/cdk-dasm
/Users/loll/.nvm/versions/node/v14.17.2/bin/dynamodump -> /Users/loll/.nvm/versions/node/v14.17.2/lib/node_modules/dynamodump/cli.js
> [email protected] postinstall /Users/loll/.nvm/versions/node/v14.17.2/lib/node_modules/aws-cdk/node_modules/aws-sdk
> node scripts/check-node-version.js
> @cloudflare/[email protected] postinstall /Users/loll/.nvm/versions/node/v14.17.2/lib/node_modules/@cloudflare/wrangler
> node ./install-wrangler.js
Downloading release from https://workers.cloudflare.com/get-npm-wrangler-binary/1.17.0/x86_64-apple-darwin
wrangler has been installed!
> [email protected] postinstall /Users/loll/.nvm/versions/node/v14.17.2/lib/node_modules/dynamodump/node_modules/aws-sdk
> node scripts/check-node-version.js
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ @cloudflare/[email protected]
added 293 packages from 258 contributors in 15.752s
Linking global packages from v14.15.1...
No linked global packages found...
Finally
❯ which cdk
/Users/loll/.nvm/versions/node/v14.17.2/bin/cdk
Sources
- https://blog.aamnah.com/node/upgrade-node-nvm-migrate-packages
Photo by Gareth Davies on Unsplash