Skip to content

Instantly share code, notes, and snippets.

Publishing pre-release versions of an NPM package

There are times when we want to be able to publish pre-release (ala SNAPSHOT in maven terminology) versions of NPM packages to the NPM registry. We want to do this so as to provide these pre-release versions to CI builds of other dependant components etc. But what we do NOT want is for these pre-release packages to be unknowingly installed by someone that simply runs npm install <packagename> (i.e. does not specify an @<version> suffix).

Key Concepts

Here are the key things you need to understand in order to be able to publish pre-release versons of packages:

  1. By default, the npm publish command publishes the package and gives a tag of latest to the version in the package.json, overwriting the lasts latest tag version.
  2. By default, the npm install command installs the package version that has the latest tag.
// From CopyArtifact plugin - CopyArtifact.java line 271: http://goo.gl/ob2HAo
if (job != null && !expandedProject.equals(project)
// If projectName is parameterized, need to do permission check on source project.
&& !canReadFrom(job, build)) {
job = null; // Disallow access
}
Building in workspace /Users/tfennelly/projects/jenkins/war/work/workspace/maven
Unpacking http://archive.apache.org/dist/maven/binaries/apache-maven-3.0.5-bin.zip to /Users/tfennelly/projects/jenkins/war/work/tools/hudson.tasks.Maven_MavenInstallation/maven305 on Jenkins
ERROR: Processing failed due to a bug in the code. Please report this to jenkinsci-users@googlegroups.com
java.lang.NullPointerException
at hudson.tools.InstallerTranslator.getToolHome(InstallerTranslator.java:69)
at hudson.tools.ToolLocationNodeProperty.getToolHome(ToolLocationNodeProperty.java:107)
at hudson.tools.ToolInstallation.translateFor(ToolInstallation.java:205)
at hudson.tasks.Maven$MavenInstallation.forNode(Maven.java:609)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:625)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:535)
@tfennelly
tfennelly / icons.css
Created June 20, 2014 22:01
icons.css
/*
* The MIT License
*
* Copyright (c) 2004-2010, Sun Microsystems, Inc., Kohsuke Kawaguchi, Daniel Dyer, Stephen Connolly
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
[INFO] Console reloading is ENABLED. Hit ENTER on the console to restart the context.
Jun 15, 2014 10:22:43 PM jenkins.InitReactorRunner$1 onAttained
INFO: Started initialization
Jun 15, 2014 10:22:43 PM hudson.PluginManager$1$3$1 isDuplicate
INFO: Ignoring /Users/tfennelly/projects/jenkins/war/work/plugins/credentials.jpi because /Users/tfennelly/projects/jenkins/war/target/jenkins/WEB-INF/plugins/credentials.hpi is already loaded
Jun 15, 2014 10:22:43 PM hudson.PluginManager$1$3$1 isDuplicate
INFO: Ignoring /Users/tfennelly/projects/jenkins/war/work/plugins/ssh-credentials.jpi because /Users/tfennelly/projects/jenkins/war/target/jenkins/WEB-INF/plugins/ssh-credentials.hpi is already loaded
Jun 15, 2014 10:22:43 PM jenkins.InitReactorRunner$1 onAttained
INFO: Listed all plugins
Jun 15, 2014 10:22:43 PM jenkins.InitReactorRunner$1 onAttained
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running CoreJellyTest
Running hudson.bugs.DateConversionTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.518 sec - in hudson.bugs.DateConversionTest
Running hudson.bugs.JnlpAccessWithSecuredHudsonTest
Tests run: 536, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 26.081 sec - in CoreJellyTest
Running hudson.bugs.LoginRedirectTest
Tests run: 3, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 28.207 sec <<< FAILURE! - in hudson.bugs.JnlpAccessWithSecuredHudsonTest
{
"customer": {
"label": "Customer",
"fields" : [
{"name":"id", "label":"Id", "provideOn": {"create": "mandatory"}},
{"name":"firstName","label":"First Name", "provideOn": {"create": "mandatory"}},
{"name":"lastName", "label":"Last Name", "provideOn": {"create": "mandatory"}},
{"name":"email","label":"Email", "provideOn": {"create": "mandatory"}}
],
"rest": "/api/customer"
package com.cloudbees.weave.sample.shopping;
import com.cloudbees.weave.api.webhook.WEAVEHook;
import com.cloudbees.weave.sample.shopping.model.Response;
import com.cloudbees.weave.sample.shopping.model.Shipment;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
package com.cloudbees.weave.sample.shopping;
import com.cloudbees.weave.sample.shopping.model.Customer;
import com.cloudbees.weave.sample.shopping.model.Response;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
package com.foxweave.mocksaas;
import com.cloudbees.weave.api.webhook.WEAVEHook;
import com.foxweave.mocksaas.model.Contact;
import com.foxweave.mocksaas.model.Response;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.POST;
import javax.ws.rs.Path;