npm prepare script not building folder in node modules

孤者浪人 提交于 2021-02-07 10:16:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!