{
"name": "bookingevents",
"version": "1.0.0",
"description": "",
"main": "./src/index.ts",
"scripts": {
"postinstall": "tsc",
"start": "node dist/src/index.js",
"dev": "ts-node-dev src/index.ts",
"build": "tsc"
},
"keywords": [],
"author": "mahmoudAlBaghdady",
"license": "ISC",
"devDependencies": {
"#types/cors": "^2.8.12",
"#types/express": "^4.17.13",
"#types/mongoose": "^5.11.97",
"#types/morgan": "^1.9.3",
"#types/node": "^17.0.41",
"ts-node-dev": "^2.0.0",
"typescript": "^4.7.3"
},
"dependencies": {
"#types/axios": "^0.14.0",
"#types/bcryptjs": "^2.4.2",
"#types/body-parser": "^1.19.2",
"#types/express-graphql": "^0.9.0",
"#types/graphql": "^14.5.0",
"#types/jsonwebtoken": "^8.5.8",
"#types/react-calendar": "^3.5.1",
"axios": "^0.27.2",
"bcryptjs": "^2.4.3",
"body-parser": "^1.20.0",
"cloudinary": "^1.30.1",
"cors": "^2.8.5",
"dotenv": "^16.0.1",
"express": "^4.18.1",
"express-async-handler": "^1.2.0",
"express-graphql": "^0.12.0",
"graphql": "^15.8.0",
"jsonwebtoken": "^8.5.1",
"morgan": "^1.10.0",
"react-calendar": "^3.7.0"
}
}
this is my package.json
Procfile
web: npm start
and this is the error I'm getting from heroku
2022-08-25T05:20:04.090743+00:00 heroku[web.1]: State changed from crashed to starting
2022-08-25T05:20:06.797284+00:00 heroku[web.1]: Starting process with command npm start
2022-08-25T05:20:09.300554+00:00 heroku[web.1]: Process exited with status 1
2022-08-25T05:20:09.452051+00:00 heroku[web.1]: State changed from starting to crashed
2022-08-25T05:20:09.075632+00:00 app[web.1]:
2022-08-25T05:20:09.075643+00:00 app[web.1]: > bookingevents#1.0.0 start
2022-08-25T05:20:09.075643+00:00 app[web.1]: > node dist/src/index.js
2022-08-25T05:20:09.075643+00:00 app[web.1]:
2022-08-25T05:20:09.136536+00:00 app[web.1]: node:internal/modules/cjs/loader:959
2022-08-25T05:20:09.136538+00:00 app[web.1]: throw err;
2022-08-25T05:20:09.136538+00:00 app[web.1]: ^
2022-08-25T05:20:09.136539+00:00 app[web.1]:
2022-08-25T05:20:09.136539+00:00 app[web.1]: Error: Cannot find module '/app/dist/src/index.js'
2022-08-25T05:20:09.136540+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
2022-08-25T05:20:09.136540+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:804:27)
2022-08-25T05:20:09.136541+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
2022-08-25T05:20:09.136541+00:00 app[web.1]: at node:internal/main/run_main_module:17:47 {
2022-08-25T05:20:09.136541+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2022-08-25T05:20:09.136542+00:00 app[web.1]: requireStack: []
2022-08-25T05:20:09.136542+00:00 app[web.1]: }
it isn't working in any way I've been trying for hours
and if someone solved it can you please explain it to me thanks alot
Related
I have an application deployed on heroku. When I run the application locally, it runs fine but in dev deployment branch I get the error below. I did some research on similar errors reported but nothing helped. The error is so vague that I have had no progress after doing alot of research and spending so much time on it. Any help would be appreciated. let me know if you need code and i will post it.
The error on heroku is:
2022-06-24T05:06:54.830575+00:00 heroku[web.1]: Starting process with command `node server.js`
2022-06-24T05:06:56.651549+00:00 app[web.1]: internal/util.js:257
2022-06-24T05:06:56.651563+00:00 app[web.1]: throw new ERR_INVALID_ARG_TYPE('original', 'Function', original);
2022-06-24T05:06:56.651564+00:00 app[web.1]: ^
2022-06-24T05:06:56.651564+00:00 app[web.1]:
2022-06-24T05:06:56.651564+00:00 app[web.1]: TypeError [ERR_INVALID_ARG_TYPE]: The "original" argument must be of type Function. Received type undefined
2022-06-24T05:06:56.651565+00:00 app[web.1]: at promisify (internal/util.js:257:11)
2022-06-24T05:06:56.651565+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/compress-brotli/src/index.js:9:18)
2022-06-24T05:06:56.651566+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:688:30)
2022-06-24T05:06:56.651566+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
2022-06-24T05:06:56.651566+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:598:32)
2022-06-24T05:06:56.651567+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
2022-06-24T05:06:56.651567+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:529:3)
2022-06-24T05:06:56.651567+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:636:17)
2022-06-24T05:06:56.651568+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:20:18)
2022-06-24T05:06:56.651568+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/keyv/src/index.js:5:24)
2022-06-24T05:06:56.651568+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:688:30)
2022-06-24T05:06:56.651569+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
2022-06-24T05:06:56.651569+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:598:32)
2022-06-24T05:06:56.651569+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
2022-06-24T05:06:56.651570+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:529:3)
2022-06-24T05:06:56.651570+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:636:17)
2022-06-24T05:06:56.803235+00:00 heroku[web.1]: Process exited with status 1
2022-06-24T05:06:56.906756+00:00 heroku[web.1]: State changed from starting to crashed
2022-06-24T05:06:56.912609+00:00 heroku[web.1]: State changed from crashed to starting
2022-06-24T05:07:14.587450+00:00 heroku[web.1]: Starting process with command `node server.js`
2022-06-24T05:07:16.213560+00:00 heroku[web.1]: Process exited with status 1
2022-06-24T05:07:16.261857+00:00 heroku[web.1]: State changed from starting to crashed
2022-06-24T05:07:16.092142+00:00 app[web.1]: internal/util.js:257
2022-06-24T05:07:16.092153+00:00 app[web.1]: throw new ERR_INVALID_ARG_TYPE('original', 'Function', original);
2022-06-24T05:07:16.092154+00:00 app[web.1]: ^
2022-06-24T05:07:16.092154+00:00 app[web.1]:
2022-06-24T05:07:16.092164+00:00 app[web.1]: TypeError [ERR_INVALID_ARG_TYPE]: The "original" argument must be of type Function. Received type undefined
2022-06-24T05:07:16.092164+00:00 app[web.1]: at promisify (internal/util.js:257:11)
2022-06-24T05:07:16.092165+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/compress-brotli/src/index.js:9:18)
2022-06-24T05:07:16.092165+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:688:30)
2022-06-24T05:07:16.092165+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
2022-06-24T05:07:16.092165+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:598:32)
2022-06-24T05:07:16.092166+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
2022-06-24T05:07:16.092166+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:529:3)
2022-06-24T05:07:16.092166+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:636:17)
2022-06-24T05:07:16.092166+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:20:18)
2022-06-24T05:07:16.092167+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/keyv/src/index.js:5:24)
2022-06-24T05:07:16.092167+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:688:30)
2022-06-24T05:07:16.092167+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
2022-06-24T05:07:16.092167+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:598:32)
2022-06-24T05:07:16.092168+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
2022-06-24T05:07:16.092168+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:529:3)
2022-06-24T05:07:16.092168+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:636:17)
package.json:
{
"name": "app",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"main": "server.js",
"heroku-postbuild": "ng build --aot --configuration=${ENV}",
"preinstall": "npm install -g #angular/cli #angular/compiler-cli typescript",
"start": "ng serve",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular-devkit/build-angular": "^0.1100.5",
"#angular/animations": "^11.0.5",
"#angular/cdk": "^11.0.3",
"#angular/cli": "11.0.5",
"#angular/common": "^11.0.5",
"#angular/compiler": "~11.2.14",
"#angular/compiler-cli": "~11.2.14",
"#angular/core": "^11.0.5",
"#angular/flex-layout": "^11.0.0-beta.33",
"#angular/forms": "^11.0.5",
"#angular/language-service": "^11.0.5",
"#angular/localize": "^11.0.5",
"#angular/material": "^11.0.3",
"#angular/platform-browser": "11.0.5",
"#angular/platform-browser-dynamic": "11.0.5",
"#angular/router": "11.0.5",
"#ng-bootstrap/ng-bootstrap": "^5.3.1",
"#ng-bootstrap/schematics": "^2.0.0-alpha.1",
"#ngtools/webpack": "^11.0.5",
"#ngx-translate/core": "13.0.0",
"#ngx-translate/http-loader": "^4.0.0",
"#types/chart.js": "^2.7.42",
"#types/chartist": "^0.11.0",
"#types/express": "^4.17.0",
"#types/jasmine": "~2.8.6",
"#types/jasminewd2": "~2.0.3",
"#types/lodash": "^4.14.135",
"#types/node": "^8.10.66",
"#types/uuid": "^8.3.0",
"#types/w3c-web-usb": "^1.0.4",
"#types/web-bluetooth": "0.0.4",
"angular-bootstrap-md": "^7.4.3",
"angular-cc-library": "^2.1.2",
"angular-cli-ghpages": "^0.6.2",
"angular-notifier": "^4.1.1",
"angular-responsive-carousel": "^2.0.2",
"angular5-csv": "^0.2.11",
"apexcharts": "^3.25.0",
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.3",
"bootstrap": "^4.5.3",
"chart.js": "^2.9.4",
"chartist": "^0.11.4",
"config": "^3.3.6",
"core-js": "^2.5.4",
"cors": "^2.8.5",
"css-loader": "^2.1.0",
"dotenv": "^6.1.0",
"exec": "^0.2.1",
"express": "^4.16.4",
"express-jwt": "^5.3.1",
"font-awesome": "^4.7.0",
"fontawesome": "^5.6.3",
"got": "^11.8.1",
"hammerjs": "^2.0.8",
"jsonwebtoken": "^8.2.2",
"lodash": "^4.17.11",
"material-design-lite": "^1.3.0",
"mdbootstrap": "^4.19.2",
"mongodb": "^3.0.10",
"mongoose": "^5.1.4",
"ng-apexcharts": "1.5.12",
"ng-chartist": "^4.1.0",
"ng-multiselect-dropdown": "^0.2.3",
"ngx-autosize": "^1.8.4",
"ngx-bootstrap": "^6.2.0",
"ngx-chess-board": "2.0.7",
"ngx-guided-tour": "^1.1.11",
"path": "^0.12.7",
"popper.js": "^1.15.0",
"protractor": "^7.0.0",
"remote-pay-cloud": "3.1.0",
"remote-pay-cloud-api": "^4.0.3",
"request": "^2.88.2",
"request-promise": "^4.2.4",
"resize-base64": "^1.0.12",
"rootpath": "^0.1.2",
"rxjs": "^6.5.2",
"rxjs-compat": "^6.3.3",
"time-ago-pipe": "^1.3.2",
"ts-node": "6.0.0",
"typescript": "4.0.5",
"uuid": "^3.3.2",
"web-animations-js": "^2.3.2",
"zone.js": "~0.10.3"
},
"devDependencies": {
"#angular-devkit/core": "^11.0.5",
"#angular-devkit/schematics": "^11.0.5",
"codelyzer": "^5.0.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~5.1.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"ng2-charts-schematics": "^0.1.7",
"protractor": "^7.0.0",
"tslint": "~6.1.3"
},
"engines": {
"node": "10.13",
"npm": "6.9.0"
}
}
The issue seemed to be in the dependencies. For anyone running into this issue, run ng update and npm audit fix --force. That will update dependencies which fixed the issue for me.
So I tried to remove some files for code cleanup and some normalization. However express then gives me an error of: "Cannot find module './jobs.resolver'" Which is one of the files I removed.
Here is my package.json:
{
"name": "typegraphql-tutorial",
"version": "1.0.0",
"main": "dist/index",
"typings": "dist/index",
"author": "Tom Nagle",
"license": "MIT",
"scripts": {
"dev": "ts-node-dev --respawn --transpile-only --exit-child --watch src src/index.ts",
"start": "node ./src/index.ts"
},
"dependencies": {
"#typegoose/typegoose": "^9.7.1",
"apollo-server": "^3.5.0",
"bcrypt": "^5.0.1",
"bcryptjs": "^2.4.3",
"class-validator": "^0.13.2",
"config": "^3.3.6",
"cookie-parser": "^1.4.6",
"dotenv": "^10.0.0",
"express": "^4.17.3",
"graphql": "15.x",
"jsonwebtoken": "^8.5.1",
"mongoose": "^6.2.9",
"nanoid": "^3.1.30",
"reflect-metadata": "^0.1.13",
"type-graphql": "^1.1.1"
},
"devDependencies": {
"#types/bcrypt": "^5.0.0",
"#types/config": "^0.0.40",
"#types/cookie-parser": "^1.4.2",
"#types/jsonwebtoken": "^8.5.6",
"ts-node-dev": "^1.1.8",
"typescript": "^4.5.2"
}
}
Here is the error stack:
Error: Cannot find module './jobs.resolver'
Require stack:
- B:\jrevsols\jrevsolsBE\src\resolvers\index.ts
- B:\jrevsols\jrevsolsBE\src\index.ts
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (B:\jrevsols\jrevsolsBE\src\resolvers\index.ts:4:1)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Module._compile (B:\jrevsols\jrevsolsBE\node_modules\source-map-support\source-map-support.js:568:25)
at Module.m._compile (C:\Users\Bon\AppData\Local\Temp\ts-node-dev-hook-9024418715050684.js:69:33)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at require.extensions.<computed> (C:\Users\Bon\AppData\Local\Temp\ts-node-dev-hook-9024418715050684.js:71:20)
[ERROR] 20:56:46 Error: Cannot find module './jobs.resolver'
Require stack:
- B:\jrevsols\jrevsolsBE\src\resolvers\index.ts
- B:\jrevsols\jrevsolsBE\src\index.ts
Not really sure why this is happening and searching the issue most of them are unreleated
I'm trying to deploy my app on Heroku, having 2 package.json files.
First is for the frontend:
{
"name": "quiz",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "npm start --prefix server",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"heroku-postbuild": "npm run build --prefix server && ng build --prod"
},
"private": true,
"dependencies": {
"#angular/animations": "~12.0.2",
"#angular/common": "~12.0.2",
"#angular/compiler": "~12.0.2",
"#angular/core": "~12.0.2",
"#angular/forms": "~12.0.2",
"#angular/platform-browser": "~12.0.2",
"#angular/platform-browser-dynamic": "~12.0.2",
"#angular/router": "~12.0.2",
"rxjs": "~6.6.0",
"tslib": "^2.1.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"#types/express": "^4.17.13",
"#angular-devkit/build-angular": "~12.0.2",
"#angular/cli": "~12.0.2",
"#angular/compiler-cli": "~12.0.2",
"#types/jasmine": "~3.6.0",
"#types/node": "^12.11.1",
"jasmine-core": "~3.8.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.7.0",
"typescript": "~4.2.3"
},
"engines": {
"node": "16.x",
"npm": "7.x"
}
}
Second is for the backend:
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "dist/index",
"scripts": {
"start": "node ./dist/server/index.js",
"dev": "nodemon index.ts",
"build": "tsc -p ."
},
"author": "",
"license": "ISC",
"devDependencies": {
"#types/express": "^4.17.13",
"#types/node": "^16.6.1",
"nodemon": "^2.0.12",
"ts-node": "^10.2.1",
"typescript": "^4.3.5"
},
"dependencies": {
"express": "^4.17.1",
"zone.js": "^0.11.4"
},
"engines": {
"node": "16.x",
"npm": "7.x"
}
}
As my package.json starts first and triggers /server/package.json - first I try to build backend, using "heroku-postbuild" command in main package.json file and after that this command builds Angular app.
But after Heroku runs "start" command it shows such mistake:
Error: Cannot find module 'express'
2021-09-18T17:16:28.140193+00:00 app[web.1]: Require stack:
2021-09-18T17:16:28.140194+00:00 app[web.1]: - /app/server/dist/server/config/express.js
2021-09-18T17:16:28.140194+00:00 app[web.1]: - /app/server/dist/server/index.js
2021-09-18T17:16:28.140199+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
2021-09-18T17:16:28.140200+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:778:27)
2021-09-18T17:16:28.140200+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19)
2021-09-18T17:16:28.140200+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:94:18)
2021-09-18T17:16:28.140201+00:00 app[web.1]: at Object.<anonymous> (/app/server/dist/server/config/express.js:6:33)
2021-09-18T17:16:28.140201+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1101:14)
2021-09-18T17:16:28.140202+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
2021-09-18T17:16:28.140202+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2021-09-18T17:16:28.140202+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2021-09-18T17:16:28.140202+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19) {
2021-09-18T17:16:28.140203+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-09-18T17:16:28.140204+00:00 app[web.1]: requireStack: [
2021-09-18T17:16:28.140204+00:00 app[web.1]: '/app/server/dist/server/config/express.js',
2021-09-18T17:16:28.140204+00:00 app[web.1]: '/app/server/dist/server/index.js'
2021-09-18T17:16:28.140205+00:00 app[web.1]: ]
2021-09-18T17:16:28.140205+00:00 app[web.1]: }
When I run all those commands locally - it works.
I solved that problem by moving "express" into my main package.json file, but that's not what I'm trying to achieve. I want to have 2 separate json files so I can handle my installed modules for each backend and frontend easily.
What am I doing wrong?
So the problem was actually that I needed to do npm install both in server and frontend folders.
Heroku has a special command 'heroku-prebuild' which helps to prepare every folder to be built.
I created such commands:
"heroku-prebuild": "npm install --prefix server && npm install",
"heroku-postbuild": "npm run build --prefix server && ng build --prod"
Firstly, Heroku runs "heroku-prebuild", which installs all npm modules for both frontend and backend and, after that, it runs "heroku-postbuild", which builds frontend and backend dist folders.
After that it runs "start": "npm start --prefix server" and everything works.
Hi while uploading my app on Heroku I am getting the following error - "throw new Error('Cannot create a client without an access token');"
const mbxGeocoding = require('#mapbox/mapbox-sdk/services/geocoding');
const geocodingClient = mbxGeocoding({ accessToken: process.env.MAPBOX_TOKEN });
This is how I am using Mapbox token through process.env.MAPBOX_TOKEN
My log file
2019-12-31T13:18:05.574782+00:00 heroku[web.1]: Starting process with command `npm start`
2019-12-31T13:18:08.114540+00:00 app[web.1]:
2019-12-31T13:18:08.114592+00:00 app[web.1]: > mnb#0.0.0 start /app
2019-12-31T13:18:08.114594+00:00 app[web.1]: > node ./bin/www
2019-12-31T13:18:08.114597+00:00 app[web.1]:
2019-12-31T13:18:09.265365+00:00 app[web.1]: /app/node_modules/#mapbox/mapbox-sdk/lib/classes/mapi-client.js:25
2019-12-31T13:18:09.265398+00:00 app[web.1]: throw new Error('Cannot create a client without an access token');
2019-12-31T13:18:09.265400+00:00 app[web.1]: ^
2019-12-31T13:18:09.265403+00:00 app[web.1]:
2019-12-31T13:18:09.265405+00:00 app[web.1]: Error: Cannot create a client without an access token
2019-12-31T13:18:09.265408+00:00 app[web.1]: at NodeClient.MapiClient (/app/node_modules/#mapbox/mapbox-sdk/lib/classes/mapi-client.js:25:11)
2019-12-31T13:18:09.265410+00:00 app[web.1]: at new NodeClient (/app/node_modules/#mapbox/mapbox-sdk/lib/node/node-client.js:7:14)
2019-12-31T13:18:09.265412+00:00 app[web.1]: at createNodeClient (/app/node_modules/#mapbox/mapbox-sdk/lib/node/node-client.js:24:10)
2019-12-31T13:18:09.265414+00:00 app[web.1]: at /app/node_modules/#mapbox/mapbox-sdk/services/service-helpers/create-service-factory.js:13:16
2019-12-31T13:18:09.265416+00:00 app[web.1]: at Object.<anonymous> (/app/middleware/index.js:7:25)
2019-12-31T13:18:09.265418+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:959:30)
2019-12-31T13:18:09.265423+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
2019-12-31T13:18:09.265425+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:815:32)
2019-12-31T13:18:09.265427+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:727:14)
2019-12-31T13:18:09.265429+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:852:19)
2019-12-31T13:18:09.265431+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2019-12-31T13:18:09.265433+00:00 app[web.1]: at Object.<anonymous> (/app/controllers/index.js:7:32)
Package.json
{
"name": "mnb",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"#mapbox/mapbox-sdk": "^0.5.0",
"#sendgrid/mail": "^6.3.1",
"body-parser": "^1.18.3",
"cloudinary": "^1.13.2",
"cookie-parser": "~1.4.3",
"debug": "~4.1.1",
"dotenv": "^8.2.0",
"ejs": "~2.6.1",
"ejs-mate": "^3.0.0",
"express": "^4.16.4",
"express-session": "^1.15.6",
"faker": "^4.1.0",
"method-override": "^3.0.0",
"mongoose": "^5.8.3",
"mongoose-paginate": "^5.0.3",
"morgan": "^1.9.1",
"multer": "^1.4.1",
"multer-storage-cloudinary": "^2.2.1",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"passport-local-mongoose": "^5.0.1",
"serve-favicon": "~2.5.0"
},
"devDependencies": {
"nodemon": "^2.0.2"
}
}
Thanks for helping!
Make sure there are no spaces when you declare your mapbox token in your .env file
Wrong:
MAPBOX_TOKEN = ckzsjnzvkqsd,mvlqdf,;ev^q;v
Correct:
MAPBOX_TOKEN=ckzsjnzvkqsd,mvlqdf,;ev^q;v
I have followed the instructions but it stil doesnt work. My repository is this:
https://github.com/diegoarcega/learning_react
Procfile
web: node index.js
index.js
var cool = require('cool-ascii-faces');
var express = require('express');
var path = require('path');
var app = express();
var DIST_DIR = path.resolve(__dirname + '/../dist');
app.set('port', (process.env.PORT || 5000));
app.use('/assets/', express.static(DIST_DIR + '/assets'));
app.get('/', function(req, res) {
res.send('hello');
});
app.get('/cool', function(request, response) {
response.send(cool());
});
app.listen(app.get('port'), function() {
console.log('Listening port ' + app.get('port'))
});
package.json
{
"name": "learning_react",
"version": "0.0.1",
"description": "practising react",
"main": "index.js",
"scripts": {
"kill": "fuser -k 30000/tcp",
"start": "node index.js",
"serve": "node index.js",
"dev": "NODE_ENV=development babel-node server/server.js",
"test": "echo \"Error: no test specified\" && exit 1",
"clean": "rimraf dist/ ",
"copy": "copyfiles -f src/index.html src/favicon.ico dist",
"prod": "npm run clean && webpack --config webpack.config.dist.js -p && npm run copy",
"dist": "NODE_ENV=production babel-node server/server.js ",
"deploy": "surge --project ./dist --domain diegoarcega-react.surge.sh"
},
"repository": {
"type": "git",
"url": "https://github.com/diegoarcega/learning_react"
},
"keywords": [
"REACT"
],
"engines": {
"node": "4.4.5",
"npm": "3.9.6"
},
"author": "Diego Arcega",
"license": "BSD-2-Clause",
"bugs": {
"url": "https://github.com/diegoarcega/learning_react/issues"
},
"dependencies": {
"axios": "^0.12.0",
"babel-polyfill": "^6.9.1",
"cool-ascii-faces": "^1.3.4",
"firebase": "^3.0.5",
"material-ui": "^0.15.1",
"muicss": "^0.6.5",
"q": "^1.4.1",
"react": "~15.1.0",
"react-dom": "~15.1.0",
"react-redux": "~4.4.5",
"react-router": "~2.4.1",
"react-tap-event-plugin": "^1.0.0",
"redux": "~3.5.2",
"redux-thunk": "^2.1.0"
},
"devDependencies": {
"babel-cli": "^6.10.1",
"babel-core": "~6.9.1",
"babel-loader": "~6.2.4",
"babel-plugin-transform-es2015-function-name": "^6.9.0",
"babel-plugin-transform-es2015-literals": "^6.8.0",
"babel-plugin-transform-es2015-template-literals": "^6.8.0",
"babel-plugin-transform-runtime": "^6.9.0",
"babel-preset-es2015": "~6.9.0",
"babel-preset-react": "~6.5.0",
"babel-preset-react-hmre": "^1.1.1",
"babel-preset-react-optimize": "^1.0.1",
"copyfiles": "^1.0.0",
"css-loader": "^0.23.1",
"express": "~4.13.4",
"file-loader": "^0.8.5",
"object-assign": "^4.1.0",
"react-css-modules": "^3.7.6",
"react-tap-event-plugin": "^1.0.0",
"react-thunk": "^1.0.0",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "~1.13.1",
"webpack-dev-middleware": "^1.6.1",
"webpack-dev-server": "^1.14.1",
"webpack-hot-middleware": "^2.10.0"
}
}
I am just trying to make it work first. The error log is this:
2016-07-06T17:00:56.197239+00:00 heroku[web.1]: State changed from crashed to starting
2016-07-06T17:01:00.211013+00:00 heroku[web.1]: Starting process with command `node index.js`
2016-07-06T17:01:01.580923+00:00 app[web.1]: module.js:327
2016-07-06T17:00:54.456548+00:00 heroku[api]: Deploy 23f2e63 by diegoarcega#gmail.com
2016-07-06T17:01:01.580940+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:2:15)
2016-07-06T17:01:01.580940+00:00 app[web.1]: at Module._compile (module.js:409:26)
2016-07-06T17:01:02.228107+00:00 heroku[web.1]: State changed from starting to crashed
2016-07-06T17:01:02.212126+00:00 heroku[web.1]: Process exited with status 1
2016-07-06T17:01:01.580941+00:00 app[web.1]: at Function.Module._load (module.js:300:12)
2016-07-06T17:01:01.580942+00:00 app[web.1]: at Function.Module.runMain (module.js:441:10)
2016-07-06T17:01:01.580939+00:00 app[web.1]: at Function.Module._load (module.js:276:25)
2016-07-06T17:01:01.580939+00:00 app[web.1]: at Module.require (module.js:353:17)
2016-07-06T17:01:01.580940+00:00 app[web.1]: at require (internal/module.js:12:17)
2016-07-06T17:01:01.580940+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:2:15)
2016-07-06T17:01:01.580940+00:00 app[web.1]: at Module._compile (module.js:409:26)
2016-07-06T17:01:01.580941+00:00 app[web.1]: at Object.Module._extensions..js (module.js:416:10)
2016-07-06T17:01:02.228107+00:00 heroku[web.1]: State changed from starting to crashed
2016-07-06T17:01:02.212126+00:00 heroku[web.1]: Process exited with status 1
2016-07-06T17:02:12.435185+00:00 heroku[slug-compiler]: Slug compilation started
2016-07-06T17:02:12.435194+00:00 heroku[slug-compiler]: Slug compilation finished
2016-07-06T17:02:12.782559+00:00 heroku[web.1]: State changed from crashed to starting
2016-07-06T17:02:17.345331+00:00 heroku[web.1]: Starting process with command `node index.js`
2016-07-06T17:02:19.470185+00:00 app[web.1]: module.js:327
2016-07-06T17:02:19.470199+00:00 app[web.1]: throw err;
2016-07-06T17:02:19.470211+00:00 app[web.1]: Error: Cannot find module 'express'
2016-07-06T17:02:19.470212+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:325:15)
2016-07-06T17:02:19.470217+00:00 app[web.1]: at Function.Module._load (module.js:300:12)
2016-07-06T17:02:19.470217+00:00 app[web.1]: at Function.Module.runMain (module.js:441:10)
2016-07-06T17:02:20.579075+00:00 heroku[web.1]: Process exited with status 1
2016-07-06T17:02:20.600663+00:00 heroku[web.1]: State changed from starting to crashed
2016-07-06T17:02:12.174712+00:00 heroku[api]: Deploy 23f2e63 by diegoarcega#gmail.com
figured it out, never forget to install express in dependencies instead of devDependencies ;)