This question already has answers here:
Simple REST app working in local but not in heroku
(3 answers)
Closed 11 months ago.
2022-03-13T12:28:53.072745+00:00 app[worker.1]: node:internal/modules/cjs/loader:1183
2022-03-13T12:28:53.072757+00:00 app[worker.1]: return process.dlopen(module, path.toNamespacedPath(filename));
2022-03-13T12:28:53.072757+00:00 app[worker.1]: ^
2022-03-13T12:28:53.072758+00:00 app[worker.1]:
2022-03-13T12:28:53.072758+00:00 app[worker.1]: Error: /app/node_modules/canvas/build/Release/canvas.node: invalid ELF header
2022-03-13T12:28:53.072758+00:00 app[worker.1]: at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
2022-03-13T12:28:53.072759+00:00 app[worker.1]: at Module.load (node:internal/modules/cjs/loader:975:32)
2022-03-13T12:28:53.072759+00:00 app[worker.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-03-13T12:28:53.072759+00:00 app[worker.1]: at Module.require (node:internal/modules/cjs/loader:999:19)
2022-03-13T12:28:53.072760+00:00 app[worker.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-03-13T12:28:53.072760+00:00 app[worker.1]: at Object.<anonymous> (/app/node_modules/canvas/lib/bindings.js:3:18)
2022-03-13T12:28:53.072760+00:00 app[worker.1]: at Module._compile (node:internal/modules/cjs/loader:1099:14)
2022-03-13T12:28:53.072761+00:00 app[worker.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
2022-03-13T12:28:53.072761+00:00 app[worker.1]: at Module.load (node:internal/modules/cjs/loader:975:32)
2022-03-13T12:28:53.072761+00:00 app[worker.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
2022-03-13T12:28:53.072762+00:00 app[worker.1]: code: 'ERR_DLOPEN_FAILED'
2022-03-13T12:28:53.072762+00:00 app[worker.1]: }
2022-03-13T12:28:53.072766+00:00 app[worker.1]:
2022-03-13T12:28:53.072766+00:00 app[worker.1]: Node.js v17.7.1
2022-03-13T12:28:53.205192+00:00 heroku[worker.1]: Process exited with status 1
Whenever I start my heroku application it crashes with the error above
I cant figure out why its doing this, the bot works completely fine running it off vscode
According to this question => Simple REST app working in local but not in heroku, the error happens because you have committed the node_modules folder to your repository. The node_modules folder contains all the modules you install, and some of them are incompatible with Heroku. So all you have to do is remove it from your repository and untrack the node_modules folder by doing:
git rm -r --cached node_modules
git commit -m "Remove node_modules from repository"
git push heroku master
Related
I am trying to setup Cypress in my laptop, but I get this error when I try to execute the example tests. I tried to clear the cypress cache and reinstall cypress, but got the same error. here is screen shot of what syntax error I receive when I hit "npm run test".
This is what I get in the terminal after I hit "npm run test"
C:\Users\u46827\AppData\Local\Cypress\Cache\10.7.0\Cypress\resources\app\node_modules\#packages\server\lib\plugins\child\run_plugins.js:40
invoke = (eventId, args = []) => {
SyntaxError: Unexpected token =
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:656:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (C:\Users\u46827\AppData\Local\Cypress\Cache\10.7.0\Cypress\resources\app\node_modules\#packages\server\lib\plugins\child\run_require_async_child.js:6:24)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
[3544:0904/215759.289:ERROR:dns_config_service.cc(278)] DNS config watch failed.
Please open screenshot here
I found the issue. My node version was old. I updated it to 16
Error: Cannot find module '.'
Require stack:
- /codebuild/output/src309915592/src/node_modules/.bin/lerna
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:831:15)
at Function.Module._load (internal/modules/cjs/loader.js:687:27)
at Module.require (internal/modules/cjs/loader.js:903:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/codebuild/output/src309915592/src/node_modules/.bin/lerna:11:3)
at Module._compile (internal/modules/cjs/loader.js:1015:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
at Module.load (internal/modules/cjs/loader.js:879:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/codebuild/output/src309915592/src/node_modules/.bin/lerna' ]
}
I get this error on running the test command:
lerna run --stream test --parallel
Also, tried with
lerna run --stream test --parallel --scope tenant-registration-service
In the services, test script looks like,
"test": "serverless-bundle test --verbose --coverage",
I installed Lerna globally in the pipeline. How do I debug this? What module is it not able to find? It looks like it already has lerna installed which it should.
npm run test command runs just fine on the local system.
This is the error I start with:
npm ERR! missing script: start
npm ERR! A complete log of this run can be found in:
npm ERR! /app/.npm/_logs/2020-08-10T10_15_35_198-debug.log
then continues from this
State changed from crashing to starting
Starting process with command `node idex.js`
State changed from starting to up
Process exited with status 1
State changed from up to crashed
still...
ReferenceError: client is not defined
at Object.<anonymous> (/app/music.js:10:1)
at Module._compile (internal/modules/cjs/loader.js:1137:20)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:100
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/app/index.js:9:11)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
What should I do?
missing script: start
You're probably using npm start [script].
You need to configure your package.json "scripts" object.
It requires a "start": "your/file" in the "scripts" object, to start with.
Here's an example.
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon src/server.js",
"dev": "src/server.js"
}
client is not defined
In music.js, line 10, you have a variable client that hasn't seemed to be defined, thus it is unable to access it.
All this leads to your file being unable to start and crashing constantly, which is shown in your second image.
I'm trying to update my project from Angular 4 to Angular 6.
I followed the update steps found on the Angular website and all goes quite smoothly.
However, when trying to use the rxjs-5-to-6-migrate script, it crashes.
I've tried various variations of paths, but noothing seems to work.
I've no idea what's going on...
PS D:\workspace\project> rxjs-5-to-6-migrate -p src/tsconfig.app.json
Running the automatic migrations. Please, be patient and wait until the execution completes.
child_process.js:615
throw err;
^
Error: Command failed: "d:\Applications\node-v9.11.1-win-x64\node_modules\rxjs-tslint\node_modules\.bin\tslint" -c "d:\Applications\node-v9.11.1-win-x64\node_modules\rxjs-tslint\rxjs-5-to-6-migrate.json" -p "src/tsconfig.app.json" --fix
at checkExecSyncError (child_process.js:575:11)
at Object.execSync (child_process.js:612:13)
at migrate (d:\Applications\node-v9.11.1-win-x64\node_modules\rxjs-tslint\rxjs-5-to-6-migrate.js:18:34)
at Object.<anonymous> (d:\Applications\node-v9.11.1-win-x64\node_modules\rxjs-tslint\rxjs-5-to-6-migrate.js:25:14)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Module.require (internal/modules/cjs/loader.js:598:17)
Apparently it was a outdated dependency (probably tslint) what caused this. After updating all dependencies in the package.json, it worked.
My app is working find locally, but when deploying to heroku one of my modules can't be found. I used a .gitignore file to ignore the node_modules folder and allow heroku to install the proper dependencies. When i run the heroku open command and search the logs using heroku logs --tail it shows this error.
The error i get is:
2015-10-21T14:42:58.415140+00:00 app[web.1]: Error: Cannot find module 'mongodb'
2015-10-21T14:42:58.415141+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:336:15)
2015-10-21T14:42:58.415142+00:00 app[web.1]: at Function.Module._load (module.js:278:25)
2015-10-21T14:42:58.415142+00:00 app[web.1]: at Module.require (module.js:365:17)
2015-10-21T14:42:58.415143+00:00 app[web.1]: at require (module.js:384:17)
2015-10-21T14:42:58.415144+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/mongoskin/lib/index.js:14:13)
2015-10-21T14:42:58.415145+00:00 app[web.1]: at Module._compile (module.js:460:26)
2015-10-21T14:42:58.415145+00:00 app[web.1]: at Object.Module._extensions..js (module.js:478:10)
2015-10-21T14:42:58.415146+00:00 app[web.1]: at Module.load (module.js:355:32)
2015-10-21T14:42:58.415146+00:00 app[web.1]: at Function.Module._load (module.js:310:12)
2015-10-21T14:42:58.415147+00:00 app[web.1]: at Module.require (module.js:365:17)
2015-10-21T14:42:59.337084+00:00 heroku[web.1]: Process exited with status 1
2015-10-21T14:42:59.348953+00:00 heroku[web.1]: State changed from starting to crashed
locally my app structure is as follows:
app/
config/
node_modules/
..
-mongodb
-mongoskin
..
public/
When I search the heroku directory using the bash I don't see the mongodb module. What could be the issue?
I've figured out the answer. I deleted the node_modules files locally and ran npm install again and node showed this warning:
npm WARN peerDependencies The peer dependency mongodb#~2.0 included from mongoskin will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
I had to declare the mongoskin dependency on mongodb explicitly in my package.json file for mongoskin direclty like this:
"dependencies": {
...
"mongoskin": "2.0.3",
"mongodb": "^2.0.46",
...
}
I pushed it to heroku and it worked.