简体   繁体   English

package.json适用于不同的环境?

[英]package.json for different environments?

I have a node.js app which I've just deployed to Heroku which depends upon the canvas module. 我有一个node.js应用程序,我刚刚部署到Heroku,这取决于canvas模块。 However, that module requires the cairo graphics library and long story short, I need to use a precomipiled version which is included with this fork of canvas . 但是,该模块需要cairo图形库和长篇故事,我需要使用这个画布前缀的预先配置版本。

Normally, my package.json dependencies look like: 通常,我的package.json依赖项看起来像:

  "dependencies" : {
    "canvas"   :  "0.10.0",
    "express" :  "2.5.6",
    "jade" : "0.20.1"
  }

But in order to get my app to work on Heroku, I must pull in the fork from github 但是为了让我的应用程序在Heroku上工作,我必须从github中获取fork

  "dependencies" : {
    "canvas"   :  "git://github.com/elspoono/node-canvas-heroku.git#master",
    "express" :  "2.5.6",
    "jade" : "0.20.1"
  }

Is it possible to have a "Heroku-only" version of package.json? 是否有可能有一个“Heroku-only”版本的package.json? Or is there another section in package.json where I can "override" the canvas dependency in dev environments? 或者在package.json中有另一个部分,我可以在dev环境中“覆盖”画布依赖性吗?

There's a tool called penv that looks promising. 有一种名为penv的工具看起来很有前途。 From their site: 从他们的网站:

Sometimes we need a different package.json properties for our different environments like production, staging and development. 有时我们需要为我们的不同环境(如生产,登台和开发)提供不同的package.json属性。 (Ex: jitsu deploys) (例如:jitsu部署)

With penv you can customize your package.json file with properties defined inside an environments.json file. 使用penv,您可以使用在environment.json文件中定义的属性自定义package.json文件。

Actually going to try it out now. 实际上现在要尝试一下。

Never used Heroku but package.json format defines the devDependencies field, see Nodejitsu cheatsheet . 从未使用过Heroku,但package.json格式定义了devDependencies字段,请参阅Nodejitsu cheatsheet Then install with $ npm install -d . 然后使用$ npm install -d

也许您可以在Git中使用Heroku特定分支并在部署之前合并(确保您不会合并到package.json)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM