Skip to content

Instantly share code, notes, and snippets.

@joe-oli
Last active November 19, 2020 17:08
Show Gist options
  • Save joe-oli/3cec280aff4cf0633502ac2120b59146 to your computer and use it in GitHub Desktop.
Save joe-oli/3cec280aff4cf0633502ac2120b59146 to your computer and use it in GitHub Desktop.
npm various commands
//view latest version only
>npm view react-scripts version
//view all versions
>npm view react-scripts versions
//#1 view all versions of a lib on the remote npm server.
>npm view react-bootstrap versions --json
[
"0.2.0",
"0.3.0",
... etc...
"0.31.5",
"0.32.0",
"0.32.1",
"0.32.2",
"0.32.3",
"0.32.4",
"1.0.0-beta.0",
"1.0.0-beta.1",
"1.0.0-beta.2",
"1.0.0-beta.3",
"1.0.0-beta.4",
"1.0.0-beta.5"
]
//#1b. only the latest version
>npm view react-bootstrap version
1.0.0-beta.5
//#1c. only all non alpha/beta versions
>npm view react-bootstrap@* version
react-bootstrap@0.2.0 '0.2.0'
react-bootstrap@0.3.0 '0.3.0'
... etc...
react-bootstrap@0.32.2 '0.32.2'
react-bootstrap@0.32.3 '0.32.3'
react-bootstrap@0.32.4 '0.32.4'
//etc..
//#1d. only a specific major versions
>npm view react-scripts@3 version
react-scripts@3.0.0 '3.0.0'
react-scripts@3.0.1 '3.0.1'
... etc
react-scripts@3.4.4 '3.4.4'
//#2. update npm version
New minor version of npm available! 6.4.1 -> 6.8.0 │
Run 'npm install -g npm' to update!
>npm install -g npm
C:\Users\joe-oli\AppData\Roaming\npm\npm -> C:\Users\joe-oli\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
C:\Users\joe-oli\AppData\Roaming\npm\npx -> C:\Users\joe-oli\AppData\Roaming\npm\node_modules\npm\bin\npx-cli.js
+ npm@6.8.0
added 54 packages from 9 contributors, removed 15 packages and updated 44 packages in 30.876s
>npm -v
6.8.0
//#3. Diff. between tilde(~) and caret(^) in package.json?
The tilde ~ matches the most recent patch version (the third number) for the specified minor version (the second number).
~1.2.3 will match all 1.2.x versions but will hold off on 1.3.0.
The caret ^ is more relaxed. It matches the most recent minor version (the second number) for the specified major version (the first number).
^1.2.3 will match any 1.x.x release including 1.3.0, but will hold off on 2.0.0.
>npm install package-name --save
prepends a caret(^) to the version number in package.json (from c.Feb 2014 onwards)
- previously it prepended a tilde(~)
//#4. todo...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment