我有一个Node项目,我想在Heroku上托管。我在package.json(位于根目录中)中明确定义了node和npm版本,如下所示:
{
"name": "*********",
"version": "0.0.0",
"private": true,
"engines": {
"node": "0.12.x",
"npm": "2.5.x"
},
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"body-parser": "^1.13.3",
...
}
然而,当我尝试将应用程序推送到heroku时
git push heroku master
Heroku试图构建应用程序,但似乎无法reed节点和npm版本。这是我得到的回应。
remote: -----> Installing binaries
remote: engines.node (package.json): unspecified
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version (latest stable) via semver.io...
remote: Downloading and installing node 4.2.1...
remote: Using default npm version: 2.14.7
为什么heroku不从package.json读取节点和npm版本?
答案 0 :(得分:6)
@rdegges是对的,因为package.json没有正确地提交给Heroku。因此,仅仅遵循Heroku说明由于某种原因对我没有用。以下是我必须做的工作才能使其发挥作用。
git clone <my git project>
heroku create <app name>
#remove package.json
mv package.json tmp_package.json
git add package.json
git commit -m "removed package.json"
#re-add package.json
mv tmp_package.json package.json
git add package.json
git commit -m "re-added package.json"
git push heroku master
答案 1 :(得分:3)
这对我有用 - 确保你实际上已经将这些更改提交给Git,并将存储库推送到Heroku。您可能还想为Heroku应用程序指定确切的Node和NPM版本号。
虽然这将适用于您已指定的变量版本,但不建议这样做,因为版本中的微小更改可能会给您带来问题。
供参考,以下是关于指定Node.js运行时的Heroku文档:https://devcenter.heroku.com/articles/nodejs-support#node-js-runtimes
答案 2 :(得分:1)
也许您的主分支不是分支未更新,尝试合并您要部署到master的分支以便使用:
const codon_dictionary = {
"A": ["GCA","GCC","GCG","GCT"],
"C": ["TGC","TGT"],
"D": ["GAC", "GAT"],
"E": ["GAA","GAG"],
"F": ["TTC","TTT"],
"G": ["GGA","GGC","GGG","GGT"],
"H": ["CAC","CAT"],
"I": ["ATA","ATC","ATT"],
"K": ["AAA","AAG"],
"L": ["CTA","CTC","CTG","CTT","TTA","TTG"],
"M": ["ATG"],
"N": ["AAC","AAT"],
"P": ["CCA","CCC","CCG","CCT"],
"Q": ["CAA","CAG"],
"R": ["AGA","AGG","CGA","CGC","CGG","CGT"],
"S": ["AGC","AGT","TCA","TCC","TCG","TCT"],
"T": ["ACA","ACC","ACG","ACT"],
"V": ["GTA","GTC","GTG","GTT"],
"W": ["TGG"],
"Y": ["TAC","TAT"],
};
const [entries, n] = [Object.entries(codon_dictionary), 3];
let [str, res] = ["AAGCATAGAAATCGAGGG", ""];
for (let i = 0; i + n <= str.length; i += n)
for (const [key, prop, curr = str.slice(i, i + n)] of entries)
if (prop.includes(curr)) {res += key; break;};
console.log(res);
答案 3 :(得分:0)
我尝试了其他解决方案,但它对我没用。但是,通过更改package.json中的name字段,它可以工作:
自:
{
...
"name": "foo"
...
}
要:
{
...
"name": "bar"
...
}
备选方案2 :
当我必须在我的另一台计算机上执行相同操作时,它没有工作,但我尝试删除package.json
,从头开始重新创建它,然后它出于某种奇怪的原因(文件元数据? ):
$ rm package.json
$ npm init
答案 4 :(得分:0)
确保锁定文件是最新的
为了更新package-lock.json
,请运行npm install
,然后将对文件的更改签入git。
然后,git add . && git commit -m "update pkg-lock" && git push heroku master
答案 5 :(得分:0)
就我而言,问题出在 package.json 上,由于一些手动更改而错过了它,因此恢复到旧版本的 repo 解决了我的问题。
答案 6 :(得分:0)
不要在版本上给出“x”
curl
写完整版。 例如
⚡ curl http://localhost:3000/svg1.svg
<svg height="100" width="100">
<circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
Sorry, your browser does not support inline SVG.
</svg> %
⚡ curl http://localhost:3000/svg2.svg
Forbidden%
⚡ curl http://localhost:3000/svg3.svg
Forbidden%