简体   繁体   English

如何在heroku命令行上调用npm(安装bower组件)?

[英]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.

相关问题 在尝试npm安装凉亭时在命令行旋转光标 - Spinning cursor at command line while trying to npm install bower 在npm中执行npm install和bower的一个命令? - One command to npm install and bower in npm? AWS - 通过npm install安装bower组件 - AWS - Installing bower components via npm install 如何编写可以从命令行(如Bower)触发的npm模块 - how to write an npm module that can be trigger from the command line like bower 我可以在没有Bower或NPM的情况下安装Angular Material库吗? - Can I install Angular Material library without Bower or NPM? 我可以在Heroku上使用Bower和Rails并仍然保留bower_components目录而不是GIT吗? - Can I use Bower and Rails on Heroku and still keep the bower_components directory out of GIT? 如何不使用bower或npm手动安装角度库并获取所有依赖项? - How can I manually install angular libraries and get all dependencies without using bower or npm? 如何在 Heroku NodeJS 服务器上安装 OracleDB NPM 包? - How can I install the OracleDB NPM package on a Heroku NodeJS server? 如何在`sbt compile`之前为Heroku部署运行`npm install && bower install`? - How to run `npm install && bower install` before `sbt compile` for Heroku Deployment? 无法将任何软件包安装到NPM或BOWER - Can't install any packages to NPM or BOWER
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM