EAzevedo
EAzevedo

Reputation: 791

How to create an application similar to create-react-app using npm package?

I have a react boilerplate that configures a nodejs server for background api calls and a create-react-app for the frontend.

I wanted to create a npm package that would prepare the whole environment when installing.

Eg.: npm i myPackage

This would create all the files and folders based on the structure I have defined, just like cloning the repository...

How could achieve that?

I just need some directions on how to start this, I published an npm package based on my repository and it only downloaded two files but not the whole structure.

Upvotes: 0

Views: 81

Answers (1)

Kossi D. T. S.
Kossi D. T. S.

Reputation: 494

Try adding a postinstall script like

"scripts": {
   "postinstall": "./executable-script or cp dir/* $INIT_CWD/"
}

into the package.json file. It will run right after the package is installed.

For more documentation read https://docs.npmjs.com/misc/scripts and https://docs.npmjs.com/cli/run-script.

I never used it before, but it would likely solve it for you.

Upvotes: 1

Related Questions