Search code examples
node.jsnpmnpm-installnpm-publish

NPM publish - install files as root files during npm install instead of inside node_modules


I am trying to publish a boilerplate project as an npm package. I have tried other solutions on the site. I want the below project files to be installed as root project files instead of node_modules. I want to publish the package in such a way that doing npm install add these files in the root. Is there any way to achieve the same? Help will be highly appreciated. Thanks

enter image description here


Solution

  • I was able to achieve the same using postinstall in package.json. Using the same command I am copying the template from my GitHub to the root directory.

    "scripts": {   
       "postinstall" : "npm i degit && npx degit tal1992/svelte-webcomponents --force"
    }