Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude test code in npm package?

Tags:

node.js

npm

The devDependencies section of npm's package.json documentation says to list your test dependencies there so that users of your package don't have to pull down extra dependencies. Would it make sense to also add my test directory to .npmignore in that case?

like image 536
Eric Bock Avatar asked Dec 23 '11 15:12

Eric Bock


People also ask

Does npm ignore Gitignore?

gitignore file, then npm will ignore the stuff matched by the . gitignore file. If you want to include something that is excluded by your . gitignore file, you can create an empty .

What is npm install -- ignore scripts?

The --ignore-scripts argument will cause npm to not execute any scripts defined in the package. json. See scripts . The --legacy-bundling argument will cause npm to install the package such that versions of npm prior to 1.4, such as the one included with node 0.8, can install the package.

Is it npm test or npm run test?

TL;DR there is no difference. It's just a shortcut for npm tests which run the test command in the package. json file. npm run test performs the same action in this case.


1 Answers

Yes that's what most people do, here are some npmignore files for popular Node.js modules:

https://github.com/socketio/socket.io/blob/ab46351a8446516fb4eea3b8333f7c0f18afaac5/.npmignore

Other people allowlist what they want published in their package.json files setting:

https://github.com/senchalabs/connect/blob/master/package.json
https://github.com/strongloop/express/blob/master/package.json

like image 144
alessioalex Avatar answered Sep 30 '22 17:09

alessioalex