[英]How can I invoke npm on heroku command line (to install bower components)?
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. Bower用于客户端Javascript npm用于服务器端并读取component.json
文件以识别应该在部署时获取的依赖项,因此我很高兴heroku将在slug编译时运行它。
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. 不幸的是,我无法从heroku控制台或一次性命令( heroku run "npm help"
)( heroku run bash
- > npm help
)调用npm或bower,因为它可以使用ruby的rake。 I've put npm and node (latest/x versions) in my package.json
but in the engines section, not the dependencies. 我把npm和node(latest / x版本)放在我的package.json
但是在引擎部分,而不是依赖项。
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. 我认为这可以通过自定义节点buildpack来解决,但我认为这对于激活一些如此明显的东西来说是一个太繁重的任务。
You can also setup a postintall
command, something like this in your package.json
您还可以在package.json
设置postintall
命令,如下所示
"dependencies": {
"bower": "0.6.x"
},
"scripts": {
"postinstall": "./node_modules/bower/bin/bower install"
}
Then npm install
will also install bower dependencies. 然后npm install
还将安装bower依赖项。
Pros : one command to rule them all. 优点 :一个命令来统治它们。
Cons : you unnecessarily embed bower as a dependency. 缺点 :您不必要地将bower嵌入作为依赖项。
你可以像这样run
:
heroku run npm install git://github.com/webjay/kaiseki
You should declare NPM dependencies in the package.json file 您应该在package.json文件中声明NPM依赖项
All you install from shell will be deleted on exit shell. 从shell安装的所有内容都将在退出shell上删除。 You are in a cloned instance. 你是一个克隆的实例。
You can use bower directly like this 您可以像这样直接使用凉亭
"dependencies": {
"bower": "^1.7.9"
},
"scripts": {
"postinstall": "sudo bower install --allow-root "
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.