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

时间:2020-12-04 12:36:37

I tried deploying Node.js API on Heroku, but shows Application Error.

我试着部署节点。Heroku上的js API,但是显示了应用程序错误。

So, used the "heroku local web" command to test any error..and got an error saying that 'babel-node' is not recognized as an internal or external command, operable program or batch file.

因此,使用“heroku本地web”命令来测试任何错误。并得到一个错误,说'babel-node'不被识别为内部或外部命令、可操作程序或批处理文件。

On the other hand, when I run the command 'npm start' I dont get any error and the server starts running.

另一方面,当我运行“npm start”命令时,我不会得到任何错误,服务器开始运行。

package.json

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
        }
      }
    }

1 个解决方案

#1


2  

I think the most likely cause is that babel is part of dev dependencies and those are not installed by default via official node.js buildpack. Change NPM_CONFIG_PRODUCTION to false and it should work.

我认为最可能的原因是babel是开发依赖项的一部分,而这些依赖项并不是通过官方节点默认安装的。js buildpack。将NPM_CONFIG_PRODUCTION更改为false,应该可以工作。

You can use command line

您可以使用命令行

heroku config:set NPM_CONFIG_PRODUCTION=false

You can always login into Heroku dyno to check if everything is installed properly

您可以随时登录Heroku dyno,检查一切是否安装正确

heroku run bash

#1


2  

I think the most likely cause is that babel is part of dev dependencies and those are not installed by default via official node.js buildpack. Change NPM_CONFIG_PRODUCTION to false and it should work.

我认为最可能的原因是babel是开发依赖项的一部分,而这些依赖项并不是通过官方节点默认安装的。js buildpack。将NPM_CONFIG_PRODUCTION更改为false,应该可以工作。

You can use command line

您可以使用命令行

heroku config:set NPM_CONFIG_PRODUCTION=false

You can always login into Heroku dyno to check if everything is installed properly

您可以随时登录Heroku dyno,检查一切是否安装正确

heroku run bash