Я ломаю голову, пытаясь развернуть приложение в Heroku. Проблема в том, что я использую ES6
с Бабелем.
Я нашел много статей об этом, но ни одна из них не помогла мне решить проблему
Даже когда я собираю приложение локально и пытаюсь запустить его, и у меня возникает другая проблема - пути в папке сборки модули остаются такими же, какими они были до компиляции Babel-build
Это обычное поведение, потому что я никогда не сталкивался с этим до
Он должен запустить API GraphQL - "heroku_path / graphql"
Буду признателен за помощь ...
пакет. json
{
"name": "cocoon-api",
"version": "1.0.0",
"description": "",
"private": true,
"main": "src/server.js",
"scripts": {
"dev": "babel-watch src/server.js",
"clean": "rm -rf build && mkdir build",
"build-babel": "babel -d ./build ./src -s",
"build": "npm run clean && npm run build-babel",
"start": "npm run build && node ./build/server.js",
"heroku-postbuild": "npm install"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"apollo-server-express": "^2.9.14",
"bcryptjs": "^2.4.3",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"graphql": "^14.5.8",
"graphql-depth-limit": "^1.1.0",
"graphql-iso-date": "^3.6.1",
"graphql-middleware": "^4.0.2",
"graphql-shield": "^7.0.6",
"graphql-tag": "^2.10.1",
"graphql-toolkit": "^0.7.5",
"graphql-tools": "^4.0.6",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.15",
"merge-graphql-schemas": "^1.7.4",
"mongoose": "^5.8.3",
"winston": "^3.2.1"
},
"devDependencies": {
"@babel/cli": "^7.7.7",
"@babel/core": "^7.7.7",
"@babel/node": "^7.7.7",
"@babel/preset-env": "^7.7.7",
"babel-plugin-import-graphql": "^2.7.0",
"babel-watch": "^7.0.0",
"dotenv": "^8.2.0",
"nodemon": "^2.0.2"
}
}
ошибка при развертывании
$ git push heroku master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 344 bytes | 344.00 KiB/s, done.
Total 3 (delta 2), 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: NPM_CONFIG_PRODUCTION=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote: NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): unspecified
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 12.x...
remote: Downloading and installing node 12.16.1...
remote: Using default npm version: 6.13.4
remote:
remote: -----> Restoring cache
remote: - node_modules
remote:
remote: -----> Installing dependencies
remote: Installing node modules (package.json + package-lock)
remote: audited 7150 packages in 8.044s
remote:
remote: 13 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: found 143 low severity vulnerabilities
remote: run `npm audit fix` to fix them, or `npm audit` for details
remote:
remote: -----> Build
remote: Detected both "build" and "heroku-postbuild" scripts
remote: Running heroku-postbuild
remote:
remote: > cocoon-api@1.0.0 heroku-postbuild /tmp/build_900f276e6b5aac117b7994386823a0a9
remote: > npm install
remote:
remote: audited 7150 packages in 8.008s
remote:
remote: 13 packages are looking for funding
remote: run `npm fund` for details
remote:
remote: found 143 low severity vulnerabilities
remote: run `npm audit fix` to fix them, or `npm audit` for details
remote:
remote: -----> Caching build
remote: - node_modules
remote:
remote: -----> Pruning devDependencies
remote: Skipping because NPM_CONFIG_PRODUCTION is 'false'
remote:
remote: -----> Build succeeded!
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 31.5M
remote: -----> Launching...
remote: Released v11
remote: https://aqueous-springs-82481.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/aqueous-springs-82481.git
5cd7f10..4abee83 master -> master
ошибка с путями
Successfully compiled 29 files with Babel.
internal/modules/cjs/loader.js:613
throw err;
^
Error: Cannot find module '../environment'
Require stack:
- C:\Users\Валерий\Documents\Projects\cocoon-api\build\server.js
структура
Procfile
web: npm run start