is the world’s largest software registry
npm was developed by Isaac Z. Schlueter
in 2009
Npm has 12 million users, and they download 5 billion packages a week.
More than 150,000 companies,
including BBC, Coinbase, eBay, Electronic Arts, Slack
rely on npm’s products and
services.
Npm is installed with Node.js.
Download and install Node.jsFind packages to use on the website
Run the following command on the command line
npm init
npm init --yes
code => test => publish => revise code => test => publish new version ...
Create a new directory and enter the following command from terminal
npm init
Enter meaningful name and appropriate details for your package. This will create the package.json for you. All NPM packages need main key. This defines the entry point to our library. By default this will be index.js but you can change it whatever you want your entry point to be.
Once your code is thoroughly tested, it is ready to be published. Run this command from the terminal
npm publish
This will publish your package to NPM registry. If you want to make changes to your package, you have to change the version number and publish again.
….
"scripts": {
"say-hello": "echo 'Hello World'"
}
Basic custom NPM script that outputs “hello world” to the consol
npm run say-hello
...
"scripts": {
"say-hello": "echo 'Hello World'",
"awesome-npm": "npm run say-hello && echo 'echo NPM is awesome!'"
}
When you run npm run awesome-npm, the second command executes after the successful execution of the first command.
It is automatically generated for any operations where npm modifies either the node_modules tree, or package.json. The goal of the file is to keep track of the exact version of every package that is installed, especially the packages of indirect dependence. It improves the installation process.
Thanks for attention
sources used
nodejs npmjs scripts