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

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

问题描述

Bower 用于客户端 Javascript 就像 npm 用于服务器端并读取 component.json 文件来识别应该在部署时获取的依赖项,所以我很高兴 heroku 会在 slug 编译时运行它.

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.

不幸的是,我无法从 Heroku 控制台或一次性命令调用 npm 或 bower (heroku run "npm help") (heroku run bash -> npm help),因为 ruby​​ 的耙子是可能的.我已将 npm 和 node(最新/x 版本)放在我的 package.json 中,但放在引擎部分,而不是依赖项.

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.

我认为这可以通过自定义 node buildpack 来解决,但我认为这有点太繁重了激活如此明显的东西.

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.

推荐答案

你也可以设置一个 postintall 命令,类似于你的 package.json

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"
}

然后 npm install 也会安装 bower 依赖项.

Then npm install will also install bower dependencies.

优点:一个命令来统治他们.

Pros : one command to rule them all.

缺点:您不必要地将 bower 作为依赖项嵌入.

Cons : you unnecessarily embed bower as a dependency.

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

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