I published a module - Module A
. I want to set this module to automatically copy a folder to the root directory AFTER installation. I created below index.js
file
//Module A - index.js`
var cpx = require('cpx');
cpx.copy('node_modules/path/to/module-a/folder/to/copy/*.*', 'dest/');
//Module A - package.json under the scripts section
"postinstall": node ./node_modules/module-a
I created a new project and installed Module A
. The postinstall
script was executed but the files were NOT copied to the destination. but if I ran the command node ./node_modules/module-a
manually again, it worked.
- Just wondering why the script was not working when running is postinstall stage.
- or there is a better way to do this copy action?