Reputation: 345
I want to update my local version, so I run npm version patch. this will update versions like this: - 1.0.0 -> 1.0.1 -> 1.0.2 -> 1.0.3
I want to set specific version like 1.0.x , you have idea how to do that ?
Thanks
Upvotes: 4
Views: 15991
Reputation: 15
This worked for me when I needed to upgrade npm to a specific version, not just the latest version.
Use npm itself to upgrade/downgrade version
npm install -g npm@<version>
Upvotes: -3
Reputation: 7708
I could not find a way to use
npm version patch <my version>
Disappointing npm version does not take an extra argument.
Instead I had to scrap the current version, split it, and update the patch myself before passing the result to npm version.
My Jenkinsfile uses something like
pipeline {
agent none
options {
timestamps ()
}
stages {
stage("Promote?") {
when {
branch 'master'
}
input {
message "Create Installers?"
}
agent {
label 'mac'
}
steps {
obtainVersion()
}
}
stage("Installers") {
parallel {
stage("OSx") {
agent {
label 'mac'
}
steps {
sh "npm version ${newVersion} --no-git-tag-version"
}
}
stage("Windows") {
agent {
label 'win'
}
steps {
bat "npm version ${newVersion} --no-git-tag-version"
}
}
}
}
}
}
// Store the version for use when creating the installers
def newVersion;
def obtainVersion() {
println "Obtaining the build version"
def version = sh script:"node -p \"require('./package.json').version\"", returnStdout: true
println "version in repo is ${version}"
def versionParts = version.tokenize( '.' )
newVersion = "${versionParts[0]}.${versionParts[1]}.${currentBuild.number}"
println "new version for build is ${newVersion}"
}
Upvotes: 1
Reputation: 10194
By default running npm install <name>
will translate to npm install <name>@latest
(or semver compatible version if ran in a folder with a package.json) you can choose the exact version with npm install <name>@<version>
doc
Upvotes: -1
Reputation: 391
First of all clean the NPM cache. You can do this using.
sudo npm cache clean -f
Install node helper (n) globally using following command.
sudo npm install -g n
Once node helper is installed. You can either get the latest stable version using
sudo n stable
Or if you want specific version like i needed 0.11.10 then you can do this using.
sudo n 0.11.10
After upgrade you can check the latest version of node using node –version or node -v.
Upvotes: -1