gauge
gauge

Reputation: 1313

How do I publish a npm package for testing?

Is there a way to publish an npm package with a prerelease version, so that I can use it specifically for testing and not affect other users who run npm install <package-name>?

I've tried setting the version to v1.0.0-0 and publishing it, I want users to continue pulling v1.0.0 from npm, but even setting such a prerelease version overrides the latest package and users will pull v1.0.0 when they run npm install <package-name>.

I do know about npm link, but I wish to test how does npm install the dependencies in my project to avoid publishing broken code.

Upvotes: 2

Views: 1799

Answers (1)

Bill Smith
Bill Smith

Reputation: 136

I know this is not the ideal solution but what about publishing a major version like 2.0.0 and make sure users use ^1.0.0 in their package.json so that when they pull they don't pull in 2.0.0 since it's a major release change. Once you are ready to publish real changes, push to say 1.2.0 and then unpublish 2.0.0

EDIT: I talked the npm people today and the way to do it is to use tags

npm publish --tag alpha

by default npm publish as latest, and that's the one users get when they pull. you can also ask your users to pull alpha to test alpha release

Upvotes: 2

Related Questions