Description
npm 5 added the ability to specify a prepare
script inside package.json. It's basically how to prepare a package before you want to publish it (build it).
When a package has a prepare script and you depend on a git source, npm will:
- Install it's devDependencies
- Run the prepare script
With it, you can depend directly on git sources without the need to publish them to npm first, which means you can depend on commits, branches or tags from a repository. For example:
"graphql": "github:graphql/graphql-js#some-new-branch"
Whenever I do a PR, it's because I need that code now and want to reference it straight away to start using it, so I typically reference my fork like: github:intellix/graphql-js#some-fix
Quote about prepare from npm docs:
prepare: Run both BEFORE the package is packed and published, and on local npm install without any arguments (See below). This is run AFTER prepublish, but BEFORE prepublishOnly.
It can essentially be a copy of the build command:
"prepare": "npm run build"
Spoke a little about this in: #1340