无法在 Heroku 中安装节点

Unable to install node in Heroku

我正在尝试使用节点和 npm 安装在 Heroku 上部署 Django 应用程序,但是,在部署应用程序时,我在 Heroku 控制台上收到以下错误:

 npm ERR! node v11.13.0
       npm ERR! npm  v2.15.12
       npm ERR! path /tmp/build_number/node_modules/.bin/grunt
       npm ERR! code ENOENT
       npm ERR! errno -2
       npm ERR! syscall unlink

       npm ERR! enoent ENOENT: no such file or directory, unlink '/tmp/build_number/node_modules/.bin/grunt'
       npm ERR! enoent This is most likely not a problem with npm itself
       npm ERR! enoent and is related to npm not being able to find a file.
       npm ERR! enoent 

       npm ERR! Please include the following file with any support request:
       npm ERR!     /tmp/build_number/npm-debug.log
-----> Build failed

我正在尝试使用使用构建包的 Vue.js 组件构建图表。我想知道如何在 Heroku 上安装 npm。任何帮助将不胜感激。

我的网站配置如下:

Django 版本:2.1.7 节点版本:11.3.0 Python版本:3.7.3

我的 package.json 文件如下所示:

{
  "name": "django",
  "private": true,
  "scripts": {
    "start": "node app",
    "poststart": "npm prune --production",
    "pretest": "eslint django/ js_tests/admin/ js_tests/gis/",
    "test": "grunt test --verbose"
  },
  "engines": {
    "node": "11.13.0",
    "npm": ">=1.3.0 <3.0.0",
    "build": "bower install && grunt build",
    "start": "nf start"
  },
  "devDependencies": {
    "@babel/core": "^7.4.3",
    "@babel/plugin-transform-runtime": "^7.4.3",
    "@babel/preset-env": "^7.4.3",
    "@babel/runtime": "^7.4.3",
    "axios": "^0.18.0",
    "babel-loader": "^8.0.5",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-stage-0": "^6.24.1",
    "bootstrap-sass": "^3.4.1",
    "css-loader": "^2.1.1",
    "eslint": "^5.16.0",
    "grunt": "^1.0.1",
    "grunt-cli": "^1.2.0",
    "grunt-contrib-qunit": "^1.2.0",
    "jquery": "^3.3.1",
    "node-sass": "^4.11.0",
    "sass-loader": "^7.1.0",
    "style-loader": "^0.23.1",
    "vue": "^2.6.10",
    "vue-hot-reload-api": "^2.3.3",
    "vue-loader": "^15.7.0",
    "vue-template-compiler": "^2.6.10",
    "webpack": "^4.29.6",
    "webpack-bundle-tracker": "^0.4.2-beta",
    "webpack-cli": "^3.3.0"
  },
  "description": "FitGirl Inc",
  "version": "1.0.0",
  "main": "index.js",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/uno-isqa-8950/fitgirl-inc.git"
  },
  "author": "hghanta",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/uno-isqa-8950/fitgirl-inc/issues"
  },
  "homepage": "https://github.com/uno-isqa-8950/fitgirl-inc#readme",
  "dependencies": {
    "chart.js": "^2.8.0",
    "vue-chartjs": "^3.4.2",
    "vue-cli": "^2.9.6"
  },
  "keywords": [
    "djano"
  ]
}

我的ProcFile如下:

web: node node_modules/gulp/bin/gulp build, gunicorn empoweru.wsgi:application --log-file -
'''

Heroku 默认启用了 Node 模块缓存。因此,当您尝试对 package.json 进行更改时,Heroku 无法识别您对 devDependencies 所做的更改。按照以下两个步骤,您应该能够部署它:

  1. 从您的 devDependencies 中删除 grunt-cli

  2. 运行 这个命令禁用缓存

    heroku config:set NODE_MODULES_CACHE=false

  3. 部署您的代码