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
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}"
}
npm version ${newVersion} --no-git-tag-version
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 -gn
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.
默认情况下,运行npm install <name>
将转换为npm install <name>@latest
(或 semver 兼容版本,如果在包含 package.json 的文件夹中运行),您可以使用npm install <name>@<version>
选择确切版本文档
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.