npm install - how to run build scripts with suffic

2019-02-11 21:59发布

问题:

I've created a node-module that has a build script that gets called after the installation. The build script clones a git repository and copies some files of it to another folder. The problem: on npm install, the script does not get sufficient permissions and I get the following error:

sh: ./build.js: Permission denied

How can I give the build script sufficient permissions to do its job?

I want that the users just can do npm install mymodule and the build-script then does its job on any system.

Any ideas?

回答1:

Do you have the x flag on build.js?

chmod +x build.js

And the first line of your script should tell how to execute the script from the shell:

#!/usr/bin/env node


标签: node.js npm