2

I've created a simple React web app and would like to publish it to NPM so that people find if easier to install (it's already published to Github).

However npm installs it by putting the whole project folder inside the node_modules folder. This of course isn't what I expected - all the project files need to be placed inside the folder from which the npm install xxx-yyy command was invoked.

Is this possible and how?

knee-cola
  • 736
  • 8
  • 17

1 Answers1

4

NPM is a place where you upload modules that can be installed globally on someones computer so they act as command line (CLI) tools under Unix system (even Windows), or are added to a project as modules.

If you created a website that you want people to use, then what you need to do is to create a CLI, that once you run it, it will create the project structure inside a folder the user selected. And from there they can run what you created.

An easy way to do this without writing everything from scratch, would be to clone this project https://www.npmjs.com/package/express-generator-dg, and replace the content of the source folder, with what you created.

I hope this helps.

David Gatti
  • 3,576
  • 3
  • 33
  • 64
  • Huh! Makes sense! Previously I published some JS components via NPM, which is really easy. This however seams to require a bit more work! Thanks for the link! – knee-cola Jun 22 '17 at 13:57
  • Components (modules) are OK. But NPM is not for releasing projects to be run. Normally you host a project on GitHub, explain how to configure it, how to run it. And then try to drive traffic to your project. – David Gatti Jun 22 '17 at 13:59
  • Yeah - I had a feeling that might be the case! Thanks! – knee-cola Jun 22 '17 at 14:01