将我的提交推送到heroku时,“代码ETARGET notarget未找到mongodb@0.7.9的匹配版本”

时间:2019-08-09 17:18:28

标签: npm-install

我使用Mongodb Express在MacOS上建立了一个本地主机网站。现在,我要将其部署到Heroku服务器。这是我在遇到错误之前使用的命令

$ git add .
$ git commit -m"Some ms"
$ git push origin master
$ heroku create 
$ git push heroku master

我推送到heroku时的错误是

    Enumerating objects: 1695, done.
    Counting objects: 100% (1695/1695), done.
    Delta compression using up to 4 threads
    Compressing objects: 100% (1332/1332), done.
    Writing objects: 100% (1695/1695), 5.41 MiB | 720.00 KiB/s, done.
    Total 1695 (delta 330), reused 1420 (delta 288)
    remote: Compressing source files... done.

    remote: Building source:
    remote:
    remote: -----> Node.js app detected
    remote:
    remote: -----> Creating runtime environment
    remote:
    remote:        NPM_CONFIG_LOGLEVEL=error
    remote:        NODE_ENV=production
    remote:        NODE_MODULES_CACHE=true
    remote:        NODE_VERBOSE=false
    remote:
    remote: -----> Installing binaries
    remote:        engines.node (package.json):  unspecified
    remote:        engines.npm (package.json):   unspecified (use default)
    remote:
    remote:        Resolving node version 10.x...
    remote:        Downloading and installing node 10.16.2...
    remote:        Using default npm version: 6.9.0
    remote:
    remote: -----> Installing dependencies
    remote:        Prebuild detected (node_modules already exists)
    remote:        Rebuilding any native modules
    remote:        body-parser@1.19.0 /tmp/build_95881850077fddd90b5770d9bd5b3b7a/node_modules/body-parser

    remote:        bytes@3.1.0 /tmp/build_95881850077fddd90b5770d9bd5b3b7a/node_modules/bytes
    remote:        content-type@1.0.4 /tmp/build_95881850077fddd90b5770d9bd5b3b7a/node_modules/content-type
    remote:        debug@2.6.9 /tmp/build_95881850077fddd90b5770d9bd5b3b7a/node_modules/debug
    remote:        ms@2.0.0 /tmp/build_95881850077fddd90b5770d9bd5b3b7a/node_modules/ms
    remote:        depd@1.1.2 /tmp/build_95881850077fddd90b5770d9bd5b3b7a/node_modules/depd
    remote:        http-errors@1.7.2 /tmp/build_95881850077fddd90b5770d9bd5b3b7a/node_modules/http-errors
    remote:        inherits@2.0.3 /tmp/build_95881850077fddd90b5770d9bd5b3b7a/node_modules/inherits
    remote:        setprototypeof@1.1.1 /tmp/build_95881850077fddd90b5770d9bd5b3b7a/node_modules/setprototypeof
    remote:        statuses@1.5.0 /tmp/build_95881850077fddd90b5770d9bd5b3b7a/node_modules/statuses
    remote:        toidentifier@1.0.0 /tmp/build_95881850077fddd90b5770d9bd5b3b7a/node_modules/toidentifier
    remote:        iconv-lite@0.4.24 /tmp/build_95881850077fddd90b5770d9bd5b3b7a/node_modules/iconv-lite
    remote:        safer-buffer@2.1.2 /tmp/build_95881850077fddd90b5770d9bd5b3b7a/node_modules/safer-buffer
    ..... 
    remote:        mongodb@2.2.36 /tmp/build_95881850077fddd90b5770d9bd5b3b7a/node_modules/mongodb
    remote:        mongodb-core@2.1.20 /tmp/build_95881850077fddd90b5770d9bd5b3b7a/node_modules/mongodb-core
    remote:        moongoose@0.0.5 /tmp/build_95881850077fddd90b5770d9bd5b3b7a/node_modules/moongoose
    remote:        ajv@4.11.8 /tmp/build_95881850077fddd90b5770d9bd5b3b7a/node_modules/moongoose/node_modules/ajv
    remote:        Installing any new modules (package.json)
    remote:        npm ERR! code ETARGET

    remote:        npm ERR! notarget No matching version found for mongodb@0.7.9
    remote:        npm ERR! notarget In most cases you or one of your dependencies are requesting
    remote:        npm ERR! notarget a package version that doesn't exist.
    remote:        npm ERR! notarget
    remote:        npm ERR! notarget It was specified as a dependency of 'mongoose'
    remote:        npm ERR! notarget
    remote:
    remote:        npm ERR! A complete log of this run can be found in:
    remote:        npm ERR!     /tmp/npmcache.VeHSV/_logs/2019-08-09T16_20_21_378Z-debug.log
    remote:
    remote: -----> Build failed
    remote:  !     Push rejected, failed to compile Node.js app.
    remote:
    remote:  !     Push failed
    remote: Verifying deploy...
    remote:
    remote: !       Push rejected to hidden-savannah-22467.
    remote:
    To https://git.heroku.com/hidden-savannah-22467.git
     ! [remote rejected] master -> master (pre-receive hook declined)
    error: failed to push some refs to 'https://git.heroku.com/hidden-savannah-22467.git' 

我尝试了$ npm cache clean --force$ npm install$ npm install mongoose --save$ npm install mongodb --save,但出现此错误

npm ERR! code ETARGET
npm ERR! notarget No matching version found for mongodb@0.7.9

npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'mongoose'
npm ERR! notarget

我的package.json文件是

{
  "name": "yelp",
  "version": "1.0.0",
  "description": "Clone of Yelp",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node app.js"
  },
  "dependencies": {
    "body-parser": "^1.19.0",
    "connect-flash": "^0.1.1",
    "ejs": "^2.6.2",
    "express": "^4.17.1",
    "express-session": "^1.16.2",
    "method-override": "^3.0.0",
    "mongodb": "^3.3.0-beta2",
    "mongoose": "0.0.5",
    "passport": "^0.4.0",
    "passport-local": "^1.0.0",
    "passport-local-mongoose": "^5.0.1",
    "request": "^2.88.0"
  }
}

有人可以帮助我安装猫鼬并部署到Heroku吗?

1 个答案:

答案 0 :(得分:0)

我通过将package.json中的猫鼬版本从0.0.5更改为^ 4.1.12来解决此错误。我在终端中执行$npm install mongoose --save时得到了0.0.5版。我不知道为什么在使用该命令时会得到这样的版本?