Publish my first npm package earlier today. Set it to v0.0.0. I've fixed a bug and done:
npm version patch -m "Bumped to version %s"
It has now been set to v0.0.1
I pushed to github (with tags) but it's not updated the npm package version on npmjs.org.
Do I need to do something else? Will it update itself?
You will have to manually publish the new version I'm afraid:
$ npm publish
npm-version doesn't seems to push into the repository: https://npmjs.org/doc/cli/npm-version.html
If you want to automate both process though, you can look at a specific Grunt task: https://github.com/geddski/grunt-release
$ grunt release
Edit:
Oh in fact, there is a standalone release plugin that works with npm (No need for Grunt if you don't want to then): https://npmjs.org/package/npm-release
Related
I'm maintaining a npm package for which I received a GitHub dependabot security alert for one of it's dependencies. I accepted the gh bot proposal which ended up in a gh pull request with an updated package-lock.json. I checked out the pr branch locally and run my tests against it. It is all ok and I want to merge it into master. But how do I publish the new package, do I have to create a new version or is it best practice to crate a new npm version? Because nothing else changed (only one dependency) can I just update the package without creating a new version? Thanks for your thoughts.
I read the npm documentation, but couldn't find any solution.
Well, I think you can try this in your terminal and will update the npm version. I think this would be helpful.
https://docs.npmjs.com/cli/v6/commands/npm-version
commands: this will update to the latest version.
npm install npm#latest -g
I'm having the gulp version of one of my projects. Previously we were using version 3.9.1 and we were hestitative updating.
After updating i have fixed all local issues and tested the project on a different computer (after updating the installed gulp there as well) it works fine.
Our automatic deployment however won't agree with me.
After a check-in our VSTS does the following steps
install npm
execute command
build project
However, this produces the following error.
Working directory changed to D:\a\1\s\MVC
Using gulpfile D:\a\1\s\MVC\gulpfile.js
C:\NPM\Modules\node_modules\gulp\bin\gulp.js:129
gulpInst.start.apply(gulpInst, toRun);
^
TypeError: Cannot read property 'apply' of undefined
at C:\NPM\Modules\node_modules\gulp\bin\gulp.js:129:20
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)
This error seems to be caused by an out of date cli version of gulp. But i can't figure out how to update this using VSTS.
Concrete problem
How do i update gulp cli in VSTS
What have i done already?
After some checking i saw the npm version installed was very old (3.10.8). I've dragged in a nodejs installer which updates to the latest version and gives me the latest version of nodejs, and a much newer version of npm (5.6.0) which i've used at on-hands computers to update the cli version. however i can't figure out how to do this in VSTS.
It seems that you are using Hosted Agent which the installed npm version is 3.10.8. You just need to add a Node Tool Installer task in your build definition and set it to use "8.x" version. It will install the 8.x version which include npm 5.6.0.
npm version before Node Tool Installer task:
npm version after Node Tool Installer task:
Try to install/update gulp-cli through NPM task:
BTW, the package in package.json will be installed on current project/folder instead of global, you need to call gulp command through npm command (scripts property of package.json) to use package in current project/folder or specify the path directly (e.g. ./node_modules/gulp/bin/gulp)
The solution that I found worked for me was to change the Pipeline from Hosted to Hosted VS2017.
I had completed a PR that upgraded the Gulp to 4.0, and the PR build completed but the CI build failed with strange results. After a lot of searching, I narrowed it down to the PR build already being set to Hosted VS2017 (it was building C# projects too that required them) and the CI build was only doing the Gulp build and was set to Hosted.
Instead of installing the latest version of an NPM package using
npm install x#latest
is there a way to view the latest stable version? something like this:
npm view x#stable version
I am looking for a programmatic/command line solution.
https://docs.npmjs.com/cli/view
Utilizing the following syntax returns the semver/value of the latest stable version only:
npm view <name> dist-tags.latest
You'll need to replace the <name> part with the actual package name.
Example:
npm view babel-cli dist-tags.latest
Running the command above currently prints 6.26.0 to the console, whilst the latest non-stable version available is the npm registry is currently 7.0.0-beta.3
Notes:
The command above will report the same version which would get installed when running:
npm install <name>#latest
Caveat: For either of the two commands to get the truly stable latest version they are reliant on the author/owner of the package having correctly managed their dist-tags. An excerpt from the docs (at the link provided) reads:
Publishing a package sets the latest tag to the published version unless the --tag option is used. For example, npm publish --tag=beta.
The problem is that if I use a command like so:
npm install -g github:user/repo#branch_x
It will not install the latest package represented by that branch_x. I currently am guessing that it just uses the master branch. But I would like to install based off of a branch other than master.
I just opened this issue with NPM
https://github.com/npm/npm/issues/17623
Has anyone seen the same issue? Anyone know a workaround?
How do I install the latest available version of an npm package? '#latest' sure doesn't fetch the latest - I assume it means the latest stable or something.
I've been using a hack for a while because I cannot seem to find any info on this:
npm i extract-text-webpack-plugin#X
The 'X' causes it to fail and dump all possible versions where I then copy and paste the correct one instead of the 'X'. Kinda ridiculous.
I've tried 3rd party packages like 'latest-version' but they all fail to get the very latest version.
There doesn't seem to be an official to do this. For example at the time of writing the latest version of extract-text-webpack-plugin is 2.0.0-beta.4. However doing:
npm i extract-text-webpack-plugin#latest
Will install '1.0.1'
I can see the latest version by doing
npm info pkg versions --json (without --json it will cut off when there are many versions)
For lack of an actual tool I guess its going to be some grep work.
Version 1.0.1 is the 'latest' version of that package - published to the npm registry at least (tagged as latest)
From the docs for cli/dist-tag. Emphasis mine.
Tags can be used to provide an alias instead of version numbers.
For example, a project might choose to have multiple streams of development and use a different tag for each stream, e.g., stable, beta, dev, canary.
By default, the latest tag is used by npm to identify the current version of a package, and npm install (without any # or # specifier) installs the latest tag. Typically, projects only use the latest tag for stable release versions, and use other tags for unstable versions such as prereleases.
By default, other than latest, no tag has any special significance to npm itself.
If you want the beta releases, then install from GitHub, or use the tags explicitly.
$ npm install webpack/extract-text-webpack-plugin
This is made pretty clear by reading the manual.
Even more clear:
latest is an implicit tag, attached to any published version of a package that was not published with an explicit tag (--tag).
Installing xyz#latest simply looks up the release tagged as latest in the registry. In the case of this package, that's release 1.0.1. That's it. There's nothing special going on here. #latest does not pull the most recent version published to npm
The versions listed as betas were tagged differently. Obviously none of them were tagged as latest, so trying to use #latest to get one is pointless.
From the registry:
'dist-tags': { latest: '1.0.1', beta: '2.0.0-beta.4' }
Again, use the GitHub releases for the bleeding edge, or use the versions/tags explicitly.
$ npm install extract-text-webpack-plugin#beta
Here you go, made especially for you:
recent-version
recent-version-cli
Condense this into a shell script, and you're good to go:
$ npm install extract-text-webpack-plugin#$(recent-version extract-text-webpack-plugin)
Use npm update as long as you have the package installed:
npm update <package>