我正在尝试将我的node.js应用程序部署到Heroku。 我已经做了必要的一切,但是我遇到了以下错误。
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/nodejs
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): 16.3.0
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 16.3.0...
remote: Downloading and installing node 16.3.0...
remote: Using default npm version: 7.15.1
remote:
remote: -----> Installing dependencies
remote: Installing node modules
remote: npm ERR! code E404
remote: npm ERR! 404 Not Found - GET https://registry.npmjs.org/har-validator/-/har-validator-5.1.2.tgz - Not found
remote: npm ERR! 404
remote: npm ERR! 404 'har-validator@https://registry.npmjs.org/har-validator/-/har-validator-5.1.2.tgz' is not in the npm registry.
remote: npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
remote: npm ERR! 404
remote: npm ERR! 404 Note that you can also install from a
remote: npm ERR! 404 tarball, folder, http url, or git url.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.7maaf/_logs/2021-06-13T18_35_23_460Z-debug.log
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: If you're stuck, please submit a ticket so we can help:
remote: https://help.heroku.com/
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: 944efd5ebf13ff49831d29f02a9a1f6565355373
remote: !
remote: ! We have detected that you have triggered a build from source code with version 944efd5ebf13ff49831d29f02a9a1f6565355373
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run:
remote: !
remote: ! git push heroku <branchname>:main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to stark-lowlands-47617.
remote:
To https://git.heroku.com/stark-lowlands-47617.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/stark-lowlands-47617.git'
我尝试做这件事:
git push heroku master:main
这是我的 package.json 文件:
{
"name": "languagelearningapp",
"engines" : { "node" : "16.3.0" },
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"basic-auth": "^2.0.1",
"bcrypt": "^3.0.2",
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.3",
"callback": "0.0.1",
"express": "^4.16.4",
"fcm-node": "^1.3.0",
"fcm-notification": "^2.0.0",
"firebase-admin": "^6.2.0",
"jsonwebtoken": "^8.3.0",
"mysql": "^2.16.0",
"nodemon": "^1.18.5",
"sendotp": "^1.2.9"
}
}
但这并没有帮助。我还尝试将Node模块添加到.gitignore中,但它没有起作用。特别是,我尝试切换到不同的分支,但效果不好。
请帮助我。
npm ERR! 404 'har-validator@https://registry.npmjs.org/har-validator/-/har-validator-5.1.2.tgz' 不在 npm 注册表中。如果你在 npm 上查找
har-validator` 这里,你会发现这个包已经被弃用了。 - Samathingamajighar-validator
被弃用的问题。其中一种解决方案建议首先升级HLS插件以消除对请求的依赖,从而避免引入har-validator,但需要注意他们使用了ArtilleryIO
。 - Alex