我如何从github安装npm模块并进行构建? [英] How can i install npm module from github and build it?

查看:253
本文介绍了我如何从github安装npm模块并进行构建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有很多带有节点模块的github仓库. 其中一些以NPM软件包的形式发布,我可以通过npm install <module>安装它. 有时github仅包含源,在package.json中我可以看到"prepublish": "npm run build",并且到NPM为止. 我也有可能从github仓库(npm install <project>/<resository>)获取模块,但是默认情况下node_modules获取源代码,然后我必须手动构建它(例如:npm run build).是否有任何选项可以从Github获取资源,然后立即进行构建?

There are a lot of github repositories with node modules. Some of them published as NPM package and i can install it via npm install <module>. And sometimes github contains only sources, and in package.json i can see "prepublish": "npm run build" and to NPM gets the bundles; Also i have possibility to get module from github repository (npm install <project>/<resository>), but by default to node_modules gets sources and then i have to build it manually (for ex: npm run build). There is any option to get sources from Github and then build it immediately?

谢谢!

推荐答案

无论来自Github,另一个SVC系统还是NPM,NPM都会自动运行生命周期步骤.在此处中查看可以将构建过程放入其中的生命周期脚本.无论您想从Github安装任何项目,都已经将其构建过程放入了相应的NPM脚本中.请注意, NPM已更改了在NPM的后4个版本中的每一个上执行这些脚本的方式和时间.

NPM will automatically run the lifecycle steps regardless of it being from Github, another SVC system or NPM. See the lifecycle scripts you can put your build processes in here. Whatever project you want to install from Github will have already put their build process in the appropriate NPM scripts. Note that NPM has changed how and when these scripts are executed on each of the last 4 versions of NPM.

在您的项目上运行npm i "jameswomack/string-is-empty#git-install-npm" -SE,然后查看它是否有效.

Run npm i "jameswomack/string-is-empty#git-install-npm" -SE on your project and see that it works.

此处中查看从Github安装的测试存储库.

See the test repo that installed from Github here

查看从生命周期脚本输出并从Github安装的测试NPM软件包分支

See the test NPM package branch that outputs froma lifecycle script and was installed from Github here

这篇关于我如何从github安装npm模块并进行构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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