npm 准备脚本未在节点模块中构建文件夹 [英] npm prepare script not building folder in node modules

查看:55
本文介绍了npm 准备脚本未在节点模块中构建文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当从不同项目安装 npm 时,我尝试使用 npm 的 prepare 脚本来运行构建步骤.

I am trying to use npm's prepare script to run a build step when npm installing from a different project.

该脚本确实在 npm install 期间运行,但是,它不会在节点模块内构建 dist 文件夹.

The script does run during the npm install however, it doesn't build out the dist folder inside node modules.

更多细节请参考这篇文章http://jim-nielsen.com/blog/2018/installing-and-building-an-npm-package-from-github/

Refer to this article for more details http://jim-nielsen.com/blog/2018/installing-and-building-an-npm-package-from-github/

推荐答案

我也遇到了同样的问题.作为依赖项安装时,我的准备脚本没有在 node_modules 文件夹中创建构建目录.

I also had the same problem. My prepare script wasn't creating the build directory in the node_modules folder when installing as dependency.

最后我发现我的 .gitignore 是问题所在,它被设置为忽略版本控制的构建目录.当找不到 .npmignore 时,NPM 会继承 .gitignore 文件,这里就是这种情况.

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.

https://docs.npmjs.com/misc/developers 所述:

如果没有 .npmignore 文件,但是有 .gitignore 文件,那么 npm 会忽略 .gitignore 文件匹配的内容

If there’s no .npmignore file, but there is a .gitignore file, then npm will ignore the stuff matched by the .gitignore file

所以我通过简单地在根目录中添加一个空的 .npmignore 来解决这个问题.

So I solved the problem by simply adding an empty .npmignore in the root.

这篇关于npm 准备脚本未在节点模块中构建文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆