How to create tgz file with version using npm pack?
above answer is valid, just adding some code and a small tip:
{ "name": "my-cool-package", "version": "1.0.0", (...rest of you package.json details) }
npm pack command in any terminal will give you my-cool-package-1.0.0.tgz.
This will have all contents from you package.
Extra info:
In case you want to ignore any file eg node_modules add those into .npmignore in the same folder and they will be ignored.
npm pack
reads the version from your package.json
file. You can set the version with the npm version
command:
npm version 1.2.3
If you don't yet have a package.json
file, create it with npm init
.