9

Npm is an amazing tool if you use it with typescript or javascript. But as far as I know, It looks like it is possible to distribute any kind of project or language via node / npm.

For example, imagine that i created a php phar file that contains some library. Could i use npm to distribute it as a package?

Or imagine that i have a css file containing a library of visual styles. Would it be accepted to distribute all those css files via npm, knowing that no javascript code would be present in the package?

The main question is this: Is it allowed to distribute non javascript projects via npm?

thanks

4
  • 4
    I guess its not allowed: "Packages that are not functionally compatible with the npm command-line client. For example, a "package" cannot simply be a PNG or JPEG image, a movie file, or a text document uploaded directly to the registry. Using the Public Registry as a general purpose database is not allowed." npmjs.com/policies/open-source-terms#acceptable-content Commented Nov 6, 2017 at 11:36
  • 1
    For what it's worth, your second example would probably be fine - libraries that are primarily/purely CSS (like Bootstrap and Pure) are distributed on NPM all the time and don't seem to have run into any issues. Your first example is probably a little fishy, though. I believe by 'functionally compatible', they mean 'someone who's working on a JavaScript project would potentially want to depend on this'. You'd have to contact NPM support to be sure though. Commented Nov 6, 2017 at 11:55
  • 1
    Yes, you can publish any folder or tarball that contains a package.json file, as long as it meets the terms of use. (publishing-npm-packages). But it may not be the best option, depending on the case. As an exemple, for a PHP module, it would probably better to use something like Composer. Commented Nov 6, 2017 at 13:37
  • There are many well known NPM packages who are purely written in C/C++ and are encapsulated behind a simple index.js file. Commented Apr 13, 2022 at 13:52

0