Skip to content

Instantly share code, notes, and snippets.

@yang-wei
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yang-wei/5a22711a5a498d8f7038 to your computer and use it in GitHub Desktop.
Save yang-wei/5a22711a5a498d8f7038 to your computer and use it in GitHub Desktop.
npm publish useful thing

To publish a package

npm publish ./

Beta version

npm publish ./ --tag beta
// to install
npm install pkname@beta

If you get error // You cannot publish over the previously published version 0.1.0

npm version {patch|minor|major} -m "commit message"
npm publish ./ --tag beta

Postinstall

Let's say we have a postinstall script to run after package is intalled. Might be useful to display logo or compile files.

// package.json
{
 scripts: {
   "6to5": babel src --out-dir lib,
   "postinstall": npm run 6to5 && ./bin/displaylogo
 }
}

This will fail for users whom do not install babel globally or using Windows platform. The workaround for this is

{ ...
 "postinstall": npm run 6to5 && node bin/displaylogo
...}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment