This thread made me think that I want to get a better grasp of what I can do through npm:
I knew about this feature and more or less know all the npm features, but I still feel a bit out of the loop about the ways people are using this tech/service. Care to fill me in on how you make use of the npm service and ecosystem?
Latest comments (36)
My favorite feature of NPM (the repository) is that I can use
pnpminstead of the default client.It might be interesting to some that NPM is open. You can take it a step further than private packages and host your own NPM server that works out of the box with the npm command line tool we all know and love by simply setting a variable to a different host than npm.org somewhere.
Just saw this and thought it was brilliant!
Hey, lots of handy stuff in the comments but I noticed nobody has mentioned this yet. You can host your own NPM server and configure NPM to use your-registry.com in stead.
There are various packages on NPM itself (such as verdaccio) that offer a NPM server. Some are minimal, other are fully featured. You can use a custom NPM server not only to make your packages private (to your team) but also to serve as proxy, or have it fallback to NPM when your registry has no package by the name of what is being queried.
npm install -g yarnnpm pack <packagename>to download tgz file of what gets installed on your machine.npm view <packagename>to view the package.json of the package.Quick one: I recently made fastjs.link as a short linking service that links directly to the homepage of an npm package. Pretty useful for blogging on dev.to, actually!
Best thing is that dev-dependencies are accessible like globals in npm scripts.
So you can run "npm i" and then simply run every script and use global packages without installing them globally.
Checking if packages are up-to-date, I sometimes
npm outdatedto list packages' current version used, wanted version and latest version...."test": "mocha ..."...npx mocha ...for one-off commands; if NPX cannot find the binary there, it will temporarily download it!npx create-react-appis awesomeOne of my pet-peeves is when a package is globally installed when it should be a devDependencies within a project. For example, if you use the TypeScript compiler in a project, "typescript" is a "devDependency"; do not make installing it globally a requirement. This lets different projects depend on different versions of the typescript compiler. It also makes it so that somebody can download your project and run a build without having to install additional dependencies. This goes for gulp, etc.
I also forgot a few:
npm info express dist-tagsNPM greater than version 5 is pretty amazing. Earlier versions, not so much. I would recommend yarn if you are stuck with earlier versions of NPM.
Oh, and don't forget that an
.npmrcfile local to your project overrides a global.npmrcfile: useful for CI servers (store a.npmrcfile with your project)!Good point on the project specific
.npmrc.Another tip is that a separate repository (and credentials) can be configured per scope as well (credit Guillaume Martigny for mentioning scoped modules first below).
This can be useful if you have some private modules in a private repository but do not wish to proxy all requests for public modules through it as well.
I also agree npm link is very useful if working on multiple modules and testing fixes.