Node.js 无法推送到Heroku:找不到模块';node-linux-x64/package.json';

Node.js 无法推送到Heroku:找不到模块';node-linux-x64/package.json';,node.js,reactjs,git,heroku,npm,Node.js,Reactjs,Git,Heroku,Npm,我真的被卡住了,非常感谢你的帮助。这个问题以前在这里被问过,尽管我尝试了所有的建议,但仍然无法解决这个问题 就像之前发布问题的那个人一样,我正在尝试将一个完整的Javascript应用程序推送到Heroku 我重新安装了所有依赖项,甚至降级了节点和npm 这个问题尤其令人困惑,因为我是一个Windows用户,所以收到关于linux模块的错误感觉很奇怪 请帮忙 C:\Users\Greg\Desktop\GregBots\reactbot> git push heroku master En

我真的被卡住了,非常感谢你的帮助。这个问题以前在这里被问过,尽管我尝试了所有的建议,但仍然无法解决这个问题

就像之前发布问题的那个人一样,我正在尝试将一个完整的Javascript应用程序推送到Heroku

我重新安装了所有依赖项,甚至降级了节点和npm

这个问题尤其令人困惑,因为我是一个Windows用户,所以收到关于linux模块的错误感觉很奇怪

请帮忙

C:\Users\Greg\Desktop\GregBots\reactbot> git push heroku master
Enumerating objects: 41, done.
Counting objects: 100% (41/41), done.
Delta compression using up to 8 threads
Compressing objects: 100% (28/28), done.
Writing objects: 100% (28/28), 19.45 KiB | 1.95 MiB/s, done.
Total 28 (delta 15), reused 0 (delta 0)
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):  13.6.0
remote:        engines.npm (package.json):   6.13.4
remote:
remote:        Resolving node version 13.6.0...
remote:        Downloading and installing node 13.6.0...
remote:        npm 6.13.4 already installed with node
remote:
remote: -----> Restoring cache
remote:        Cached directories were not restored due to a change in version of node, npm, yarn or stack
remote:        Module installation may take longer for this build
remote:
remote: -----> Installing dependencies
remote:        Installing node modules (package.json + package-lock)
remote:
remote:        > node@13.8.0 preinstall /tmp/build_5798122e415d759253929a4b5b0a6c16/node_modules/node
remote:        > node installArchSpecificPackage
remote:
remote:        npm ERR! code ETARGET
remote:        npm ERR! notarget No matching version found for node-linux-x64@13.8.0.
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:
remote:        npm ERR! A complete log of this run can be found in:
remote:        npm ERR!     /tmp/npmcache.3VsTs/_logs/2020-02-26T01_02_25_357Z-debug.log
remote:        internal/modules/cjs/loader.js:976
remote:          throw err;
remote:          ^
remote:
remote:        Error: Cannot find module 'node-linux-x64/package.json'
remote:        Require stack:
remote:        - /tmp/build_5798122e415d759253929a4b5b0a6c16/node_modules/node/installArchSpecificPackage.js
remote:            at Function.Module._resolveFilename (internal/modules/cjs/loader.js:973:15)
remote:            at Function.resolve (internal/modules/cjs/helpers.js:78:19)
remote:            at ChildProcess.<anonymous> (/tmp/build_5798122e415d759253929a4b5b0a6c16/node_modules/node-bin-setup/index.js:18:27)
remote:            at ChildProcess.emit (events.js:321:20)
remote:            at maybeClose (internal/child_process.js:1028:16)
remote:            at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) {
remote:          code: 'MODULE_NOT_FOUND',
remote:          requireStack: [
remote:            '/tmp/build_5798122e415d759253929a4b5b0a6c16/node_modules/node/installArchSpecificPackage.js'
remote:          ]
remote:        }
remote:        npm ERR! code ELIFECYCLE
remote:        npm ERR! errno 1
remote:        npm ERR! node@13.8.0 preinstall: `node installArchSpecificPackage`
remote:        npm ERR! Exit status 1
remote:        npm ERR!
remote:        npm ERR! Failed at the node@13.8.0 preinstall script.
remote:        npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote:        npm ERR! A complete log of this run can be found in:
remote:        npm ERR!     /tmp/npmcache.3VsTs/_logs/2020-02-26T01_02_26_775Z-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:        Some possible problems:
remote:
remote:        - A module may be missing from 'dependencies' in package.json
remote:          https://devcenter.heroku.com/articles/troubleshooting-node-deploys#ensure-you-aren-t-relying-on-untracked-dependencies
remote:
remote:        Love,
remote:        Heroku
remote:
remote:  !     Push rejected, failed to compile Node.js app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to infinite-sea-94371.
remote:
To https://git.heroku.com/infinite-sea-94371.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/infinite-sea-94371.git'
PS C:\Users\Greg\Desktop\GregBots\reactbot>

此错误可能由多个原因引起:

  • 根据您的错误,npm包
    node-linux-x64
    设置为不存在的错误版本。删除
    node-linux-x64
    ,因为Heroku为其系统安装了node.js的最新版本,或者将其设置为现有版本
  • 您是否用代码推送了package.json文件
  • 您已将node_模块推送到Heroku,Heroku拥有某些软件包的特定版本,这些软件包只能在您的发行版/OS上运行
  • 您可能已经全局安装了npm包,但忘记将其包含到packages.json文件中

您是否正在部署mern应用程序?Eureka!成功了。谢谢你,玛赞。我想你说的是对的,我在全球范围内安装,但没有将其包含在package.json中。你就是那个人!不客气!请批准我的回答,让其他人知道。如果您对Node.js或web dev有任何问题,请在StackOverflow上写下您的问题并与我联系。祝你好运我刚意识到你的问题还没有解决。哈哈。你能试着从packages.json文件中删除engine对象并试一试吗?2天前,当它解决了我的问题后,我就批准了你的答案。不幸的是,根据stackoverflow,我没有足够的“代表”来更改公共显示,即批准号。
    {
  "name": "reactbot",
  "version": "1.0.0",
  "description": "React bot",
  "main": "index.js",
  "engines": {
    "node": "13.6.0",
    "npm": "6.13.4"
  },
  "scripts": {
    "start": "node index.js",
    "backend": "nodemon index.js",
    "frontend": "npm run start --prefix client",
    "dev": "concurrently \"npm run backend\" \"npm run frontend\"",
    "heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "actions-on-google": "^2.12.0",
    "body-parser": "^1.19.0",
    "dialogflow": "^1.2.0",
    "dialogflow-fulfillment": "^0.6.1",
    "express": "^4.17.1",
    "mongoose": "^5.9.2"
  },
  "devDependencies": {
    "concurrently": "^5.1.0",
    "nodemon": "^2.0.2"
  }
}