我如何在heroku命令行上调用npm(安装bower组件)? [英] How can I invoke npm on heroku command line (to install bower components)?

查看:112
本文介绍了我如何在heroku命令行上调用npm(安装bower组件)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Bower 适用于客户端Javascript,npm是服务器端,并读取组件。 json 文件来识别应该在部署时获取的依赖关系,所以我很高兴它可以在slug编译时运行它。



不幸的是,我无法从heroku控制台或一次性命令调用npm或bower( heroku runnpm help heroku run bash - > npm help )。我把npm和node(最新/ x版本)放在我的 package.json 中,但在引擎部分,而不是依赖关系。



我认为这可以通过自定义节点buildpack

a>但我认为这是一个太重的任务,只是为了激活一些如此明显的事情。 您的 package.json

 dependencies:{
bower:0.6.x
},
scripts:{
postinstall:./node_modules/bower/bin/bower install
}

然后 npm install 也会安装bower依赖关系。



:一个命令可以统治所有这些命令。
$ b

:您不必要地将bower嵌入为依赖项。


Bower is for client side Javascript what npm is for the server side and reads a component.json file to recognize dependencies that should be fetched at deploy time so I'd be happy it heroku would run it at slug compilation time.

Unfortunately I can not invoke npm or bower from a heroku console or one-off command (heroku run "npm help") (heroku run bash -> npm help) as it's possible with ruby's rake. I've put npm and node (latest/x versions) in my package.json but in the engines section, not the dependencies.

I think this could be solved by customizing the node buildpack but I consider this a little too heavy task just for activating something so obvious.

解决方案

You can also setup a postintall command, something like this in your package.json

"dependencies": {
    "bower": "0.6.x"
},
"scripts": {
    "postinstall": "./node_modules/bower/bin/bower install"
}

Then npm install will also install bower dependencies.

Pros : one command to rule them all.

Cons : you unnecessarily embed bower as a dependency.

这篇关于我如何在heroku命令行上调用npm(安装bower组件)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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