问题
I am trying to use npm's prepare
script to run a build step when npm installing from a different project.
The script does run during the npm install
however, it doesn't build out the dist
folder inside node modules.
Refer to this article for more details http://jim-nielsen.com/blog/2018/installing-and-building-an-npm-package-from-github/
回答1:
I also had the same problem. My prepare script wasn't creating the build directory in the node_modules folder when installing as dependency.
Finally I found out that my .gitignore was the problem, which was setup to ignore the build directory for version control. NPM is inheriting the .gitignore file when no .npmignore can be found, which was the case here.
As stated on https://docs.npmjs.com/misc/developers:
If there’s no .npmignore file, but there is a .gitignore file, then npm will ignore the stuff matched by the .gitignore file
So I solved the problem by simply adding an empty .npmignore in the root.
来源:https://stackoverflow.com/questions/52116189/npm-prepare-script-not-building-folder-in-node-modules