gpt4 book ai didi

node.js - Babel 并将 Nodejs 部署到 Google App Engine

转载 作者:太空宇宙 更新时间:2023-11-03 22:43:48 26 4
gpt4 key购买 nike

我是一个nodejs新手。我在将 Nodejs 应用程序部署到 google 应用程序引擎时遇到问题。这是我的错误,我一直在尝试修复它,但它不起作用。我已经安装了 babel。

错误

Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9] Application startup error:

restaurant_api@1.0.0 prestart /app npm run -s build

You have mistakenly installed the babel package, which is a no-op in Babel 6. Babel's CLI commands have been moved from the babel package to the babel-cli package.

npm uninstall babel

npm install --save-dev babel-cli

这是我的 package.json

 "main": "dist",
"scripts": {
"dev": "NODE_ENV=development nodemon -w src --exec \"babel-node src --presets es2015,stage-0\"",
"build": "babel src -s -D -d dist --presets es2015,stage-0",
"start": "NODE_ENV=production pm2 start dist",
"prestart": "npm run -s build",
"lint": "eslint src",
"test": "echo \"Error: no test specified\" && exit 1",
"babel-version": "babel --version"
},
"eslintConfig": {
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"env": {
"node": true
},
"rules": {
"no-console": 0,
"no-unused-vars": 1
}
},
"author": "",
"license": "ISC",
"dependencies": {
"babel": "^6.23.0",
"body-parser": "^1.17.0",
"express": "^4.15.0",
"express-jwt": "^5.1.0",
"jsonwebtoken": "^7.3.0",
"mongoose": "^4.8.5",
"passport": "^0.3.2",
"passport-local": "^1.0.0",
"passport-local-mongoose": "^4.0.0",
"pm2": "^2.4.2"
},
"devDependencies": {
"babel-cli": "^6.23.0",
"babel-eslint": "^7.1.1",
"babel-preset-es2015": "^6.22.0",
"babel-preset-stage-0": "^6.22.0",
"eslint": "^3.16.1"
}

最佳答案

问题很简单,如果你明显注意到GAE,没有安装dev-dependencies。因此,将您的 dev-deps 移至 deps 内部上方,就像我所做的那样,并且 babel nofound 错误消失了。

    {
"name": "scraping",
"version": "0.3.0",
"description": "Starter project for an ES6 RESTful Express API",
"main": "dist",
"scripts": {
"dev": "nodemon -w src --exec \"babel-node src --presets es2015,stage-0\"",
"build": "babel src -s -D -d dist --presets es2015,stage-0",
"start": "node dist",
"prestart": "npm run -s build",
"test": "eslint src"
},
"eslintConfig": {
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
},
"env": {
"node": true
},
"rules": {
"no-console": 0,
"no-unused-vars": 1
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/developit/express-es6-rest-api.git"
},
"author": "Saransh Sharma <jason@developit.ca>",
"license": "MIT",
"dependencies": {
"body-parser": "^1.13.3",
"compression": "^1.5.2",
"cors": "^2.7.1",
"express": "^4.13.3",
"morgan": "^1.8.0",
"resource-router-middleware": "^0.6.0",
"@jonstuebe/scraper": "^0.1.4",
"babel-cli": "^6.9.0",
"babel-core": "^6.9.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-stage-0": "^6.5.0",
"eslint": "^3.1.1",
"nodemon": "^1.9.2"
},
"devDependencies": {
"babel-cli": "^6.9.0",
"babel-core": "^6.9.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-stage-0": "^6.5.0",
"eslint": "^3.1.1",
"nodemon": "^1.9.2"
},
"bugs": {
"url": "https://github.com/developit/express-es6-rest-api/issues"
},
"homepage": "https://github.com/developit/express-es6-rest-api#readme",
"keywords": [
"scraper",
"product",
"from",
"amazon"
]
}

关于node.js - Babel 并将 Nodejs 部署到 Google App Engine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42652591/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com