Here, in this article we’re going to take a glimpse on some of the tips and tricks that developers shall know while working with NPM.
- Use shortcuts in command: Using shortcuts in command is really helpful in saving your time and energy so that developers can focus more on increasing productivity.
For instance, use npm i <package> instead of npm install <package>
npm i -G <package> instead of npm install –global <package>
- Combine and simplify: Simplifying the process by combining two or more commands that provide the same results as separated. It will save time plus brainstorm the mind to think creatively.
- Link the packages: Once in a while you need to deal with a project and foster its packages simultaneously. Submitting and pushing your package to a distant store for each change you need to give a shot is tedious! All things being equal, you can utilize an element called package connecting.
Package connecting works by making a symlink in your node_modules envelope that focuses on the neighborhood store of your bundle. Along these lines, you can alter packages locally and the progressions will be in a split second accessible in the undertaking utilizing it.
The least demanding way of understanding package connecting is to give it a shot!
Suppose we have a venture called myproject and a bundle called mypackage. We need mypackage to be a dependency of myproject.
- Use npm scripts: Using npm scripts make the task even simpler for the beginners. Npm offers some predefined scripts like start, install, test, prepublish. Developers can also customize the scripts according to the requirements.
- Default values in npm: While making another venture, you will run npm init and you will be posed inquiries about your task. To save time you’ll presumably compose run npm init – y to fill in the package.json with default esteems.