Can't update to newer version of AWS-CDK - npm

I have aws-cdk version 2.44.0.
I've got notified (after running cdk diff) that there is a newer version, 2.47.0, and I should run npm install -g aws-cdk to upgrade to this version. I ran this command successfully with sudo (since without it I get errors) and got the following output:
changed 1 package, and audited 2 packages in 2s
found 0 vulnerabilities
but after check with cdk --version I found that the version is still 2.44.0.
additional information:
Ubuntu 20.04.4 LTS
Node.js v16.17
npm version: 8.19.2
So, how to update aws-cdk successfuly?

It turned out that this old version was installed using older version of npm which installed it in usr/local/bin, while the newer version of npm installed the latest version of cdk in usr/bin. After locally uninstalled the older version and running again which cdk it finally recognized the newer version in usr/bin.

Related

How do I change the default path for Bazel when multiple version installed?

I got a message that I needed to upgrade to the newest version of Bazel to build Tensorflow. I followed the instructions for installing bazel using apt-get and it says I have 0.7.0 installed.
However when I issue the command "bazel version", I am still seeing the older 0.4.5 version installed. When I issue "whereis bazel" I get the following results:
bazel: /usr/bin/bazel /etc/bazel.bazelrc /usr/local/bin/bazel /usr/local/lib/bazel
The version at /usr/bin/bazel is the newest version 0.7.0. However the version at /usr/local/bin/bazel is the older version 0.4.5.
I am somewhat new to Linux, but assume there has got to be a way to change the pointer for the path for when I call bazel directly. Is this assumption correct? Any ideas? Thanks!
You should just remove your installation under /usr/local/bin/bazel which was probably installed with an older shell installer: sudo rm /usr/local/bin/bazel

npm update is not honoring the results of npm outdated

I ran npm outdated on a project - it showed that there were several outdated packages. So I ran npm update - it updated a few packages but not all. If I run npm outdated again it still shows the remaining packages that are outdated:
Package Current Wanted Latest
babel-loader 7.1.1 7.1.1 7.1.2
babel-runtime 6.23.0 6.23.0 6.26.0
chalk 2.0.1 2.0.1 2.1.0
css-loader 0.28.4 0.28.4 0.28.5
eslint 4.2.0 4.2.0 4.5.0
eslint-plugin-react 7.1.0 7.1.0 7.2.1
fs-extra 4.0.0 4.0.0 4.0.1
html-webpack-plugin 2.29.0 2.29.0 2.30.1
material-ui 1.0.0-beta.5 1.0.0-beta.5 0.19.0
postcss-flexbugs-fixes 3.0.0 3.0.0 3.2.0
react-stripe-elements 0.0.2 0.0.2 0.0.7
webpack 3.3.0 3.3.0 3.5.5
webpack-dev-server 2.5.1 2.5.1 2.7.1
webpack-manifest-plugin 1.1.2 1.1.2 1.3.1
If I try to run npm update again, it does nothing!
Why are the two commands telling me different things?
Thanks in advance.
If you run npm update and some of the packages defined in package.json have their version pinned, it will not update. That is why you see three columns when you run npm outdated. The current installed version, the latest version that matches what is defined in your package.json, and finally, the actual latest version.

Use NVM To Install Latest NodeJS For Specific Major Version

I want to install the latest minor/patch version of NodeJS 4 using nvm. I don't just want "latest", because that would be NodeJS 8 or whatever later, potentially breaking-change version is out now.
If it were an npm dependency, I would be able to say nvm install "^4", but that doesn't work. Is there a simple command to do this? If there isn't, is there something I can do on the command line to find the latest version and install it in a one-liner that works on both Windows and Unix-based consoles?
(nvm maintainer here)
If you run nvm --help (make sure you're using the latest version of nvm), you'll see a description of all the things nvm supports. Specifically, nvm does not support semver ranges, however, nvm install 4 or nvm install 4.x will install the latest available version of node 4.
Separately, you can use nvm install --lts=argon (and nvm alias default lts/argon if you want to peg to the LTS line specifically instead of just v4.

How do I change the version of yarn used?

I used Homebrew to install yarn. Running yarn -v shows that I currently use 0.23.2. I ran brew upgrade yarn to get the latest version, which is 0.24.6.
After Homebrew successfully upgrades yarn, I run yarn -v again, but the version is still 0.23.2. How can I change the version of yarn that I am running?
yarn policies set-version <version number>
Per https://github.com/yarnpkg/yarn/issues/7146#issuecomment-477809216
You can use homebrew and yarn formula URLs to install older versions of yarn, then brew switch between yarn versions as needed. Works perfectly! Credit to github user robertmorgan.
First off, if you already have a version installed, unlink it from brew running the brew unlink yarn command in your terminal.
Next, in a web browser, find the Pull Request that has been merged which contained the formula (version) of
Yarn
that you want to install.
View the files changed in that Pull Request - there should be one for Formula/yarn.rb.
Click the "View" button for the Formula/yarn.rb file to see the whole contents of the file for that commit.
Click the button to view the "Raw" version of that file. This will open a url which should start with
https://raw.githubusercontent.com/....
This is the URL that you will need for the next step - so copy the complete URL to your clipboard.
Back in your terminal window, use the command brew install followed by the URL that you've copied.
e.g. to install v1.6.0 of yarn it would be:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/fba7635ab69384ac980c635483a7af825bc06088/Formula/yarn.rb
You can then verify the versions available to Homebrew by running:
brew list --versions yarn, and switch between versions using brew switch yarn VERSION_NUMBER
Source: https://github.com/yarnpkg/yarn/issues/1882#issuecomment-421372892
I found an answer. It's not the prettiest, but since yarn always tell me what the most update-to-date version is, I can use npm to just install the latest version.
If the latest is 0.24.6
npm install --global yarn#.24.6
EDIT:
According to yarn's official documentation, the way to install/upgrade is:
brew install yarn
brew upgrade yarn
https://yarnpkg.com/en/docs/install#mac-stable
Your best bet would be to use a yarn version manager.
Install:
curl -fsSL https://raw.githubusercontent.com/tophat/yvm/master/scripts/install.sh | bash
Single usage:
yvm exec <version> <command>
Or to switch your currently running yarn version
yvm use <version>
yarn --version
UPDATE Dec 2021:
Sadly brew switch is deprecated in Homebrew 2.6.0 (December 2020)
$ brew switch
Error: Unknown command: switch
TLDR, to switch version:
brew unlink yarn
brew link yarn#<new_version>
Old solution:
Assuming that you have the other version installed, you can run
brew switch yarn <old_version>
To list the versions you have installed:
brew list --versions yarn
You can use
yarn set version <version>
For example, if you want the latest version, you can run
yarn set version latest
You can also set it to a specific number, for example,
yarn set version 1.22.1
You can view the full documentation at the official website.
Note 1: A bug stops you from switching from yarn 2 to yarn 1. There are solutions to this in this GitHub issue.
Note 2: I don't use brew, but this solution should still work.
Easily install and switch between any number of yarn versions.
https://github.com/tophat/yvm
Here's a way to do it with only curl and bash:
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 0.24.6 # or another version
This works whether you have yarn installed or not.
For updating version on macOS use below command:
$ brew upgrade yarn
Some of the above answers don't seem to work anymore. Here is how I was able to install a different version in April 2021:
brew unlink yarn#1.6.0 (If you already have a version installed)
brew extract --version 1.22.4 yarn homebrew/cask
brew install yarn#1.22.4
yarn -v

What does 'npm outdated --depth=0 ' mean to do as ask action when seeing differences?

When running the command npm outdated --depth=0 I see the following:
Package Current Wanted Latest Location
cordova 5.4.1 5.4.1 6.0.0 cordova
grunt-angular-templates 0.5.9 0.5.9 1.0.3 grunt-angular-templates
grunt-autoprefixer 0.4.2 0.4.2 3.0.4 grunt-autoprefixer
grunt-bump 0.3.4 0.3.4 0.7.0 grunt-bump
...
What does those differences between 'Current', 'Wanted' and 'Latest' mean to me? Respectively what am I supposed to do in case?
Current: Current version of the packages installed.
Wanted: The maximum version of the package that satisfies the semver range specified in package.json. If there's no available semver range (i.e. you're running npm outdated --global, or the package isn't included in package.json), then wanted shows the currently-installed version.
Latest: The version of the package tagged as latest in the registry. Running npm publish with no special configuration will publish the package with a dist-tag of latest. This may or may not be the maximum version of the package, or the most-recently published version of the package, depending on how the package's developer manages the latest dist-tag.
Reference: https://docs.npmjs.com/cli/outdated