运行heroku本地网络时无法识别babel-node

时间:2017-03-07 14:21:15

标签: node.js heroku ecmascript-6 babel

我尝试在Heroku上部署Node.js API,但显示应用程序错误。

所以,使用" heroku本地网站"命令测试任何错误..并得到一个错误说' babel-node'不被识别为内部或外部命令,可操作程序或批处理文件。

另一方面,当我运行命令' npm start' 时,我没有收到任何错误,服务器开始运行。

的package.json

 {
      "name": "apollo-starter-kit",
      "version": "0.1.0",
      "description": "Minimal set of code to write a GraphQL server with Apollo graphql-tools",
      "scripts": {
        "start": "nodemon ./server.js --exec babel-node",
        "test": "echo \"Error: no test specified\" && exit 1",
        "lint": "eslint ."
      },
      "repository": {
        "type": "git",
        "url": "git+https://github.com/apollostack/apollo-starter-kit.git"
      },
      "keywords": [
        "Node.js",
        "Javascript",
        "GraphQL",
        "Express",
        "Apollo",
        "Meteor"
      ],
      "author": "Jonas Helfer <jonas@helfer.email>",
      "license": "MIT",
      "bugs": {
        "url": "https://github.com/apollostack/apollo-starter-kit/issues"
      },
      "homepage": "https://github.com/apollostack/apollo-starter-kit#readme",
      "dependencies": {
        "apollo-server": "^0.1.2",
        "casual": "^1.5.10",
        "cors": "^2.8.1",
        "express": "^4.13.4",
        "lodash": "^4.17.4",
        "mongoose": "^4.8.1",
        "sequelize": "^3.30.2",
        "sqlite": "^2.3.0"
      },
      "devDependencies": {
        "babel-cli": "6.5.1",
        "babel-core": "^6.5.2",
        "babel-eslint": "^6.0.0-beta.6",
        "babel-loader": "6.2.3",
        "babel-plugin-inline-import": "^2.0.1",
        "babel-polyfill": "6.5.0",
        "babel-preset-es2015": "6.5.0",
        "babel-preset-react": "^6.5.0",
        "babel-preset-stage-0": "6.5.0",
        "casual": "^1.5.10",
        "eslint": "^2.4.0",
        "eslint-config-airbnb": "^6.1.0",
        "eslint-plugin-import": "^1.1.0",
        "eslint-plugin-react": "^4.2.3",
        "graphql": "^0.6.0",
        "nodemon": "^1.9.1"
      },
      "peerDependencies": {
        "graphql": "^0.5.0 || ^0.6.0"
      },
      "eslintConfig": {
        "parser": "babel-eslint",
        "extends": [
          "airbnb/base",
          "plugin:import/errors"
        ],
        "rules": {
          "no-use-before-define": 0,
          "arrow-body-style": 0,
          "dot-notation": 0,
          "no-console": 0
        },
        "env": {
          "mocha": true
        }
      }
    }

2 个答案:

答案 0 :(得分:3)

我认为最可能的原因是babel是dev依赖项的一部分,默认情况下不会通过官方node.js buildpack安装它们。将NPM_CONFIG_PRODUCTION更改为false,它应该有效。

您可以使用命令行

heroku config:set NPM_CONFIG_PRODUCTION=false

您可以随时登录Heroku dyno以检查是否所有内容都已正确安装

heroku run bash

答案 1 :(得分:0)

您不应在生产中使用babel-node。由于缓存存储在内存中,因此不必要地增加了内存使用量。您还将始终遇到启动性能下降的麻烦,因为整个应用程序需要动态编译。

ref:https://medium.com/@Cuadraman/how-to-use-babel-for-production-5b95e7323c2f

相关问题