4

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

5 Answers 5

9
npm version ${newVersion} --no-git-tag-version 
Sign up to request clarification or add additional context in comments.

1 Comment

this worked for me, skipped the --no-git-tag-version flag because I actually want the tag
1

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}" } 

Comments

-1

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.

1 Comment

Thank you, but I want to update my local package. I have project that need to upload it to local repository. so i want to set hardcoded the version number
-1

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

5 Comments

I need to set the version local, to my local project, and not for installing specific version
Then use the exact version in your package.json instead of the "Compatible with version" : ^version doc use "foo": "1.0.1" instead of "foo": "^1.0.1"
You can save the exact version when installing a module with the --save-exact option
He's talking about the package.json version of the project being developed. i.e. Not a dependency.
In this case you can use npm version <newversion>
-3

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>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.