I wonder if I can initialize a new Node project using an existing package as a template? Instead of having the package as a dependency, I would like the project to be a copy of the package.
CodePudding user response:
I was able to solve this by using npm pack <package>
. It downloads the package as a tarball. Unfortunately, it seems like there is not a similar function for yarn
to download a package this way.
CodePudding user response:
Look at the npm init command. You can create your own CLI which installs the package, copies files into the target directory, then removes the package. If you follow npm
documentation your installer could be run in this way:
npm init <installer-name>
or:
npm init @scope/<installer-name>
Using npm init
(or npm create
which is an alias to npm init
) is also compatible with: yarn create