cannot find module 'mongdb' heroku mongoskin - bash

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.

Related

Heroku Application crashing on startup discordjs [duplicate]

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

External Adapter repo throwing syntax error out of the box

I'm looking to create my own external adapter. I pulled the external adapter repo and set it up with yarn per the README. However, when I try running cd packages/sources/coingecko && yarn start within any of the adapter directories, I get the following error:
/Users/jvilla/Documents/GitHub/external-adapters-js/packages/core/bootstrap/dist/lib/cache/index.js:73
if (!context?.cache?.instance)
^
SyntaxError: Unexpected token '.'
at wrapSafe (internal/modules/cjs/loader.js:1053:16)
at Module._compile (internal/modules/cjs/loader.js:1101:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.external_module_.Module._load (/Users/jvilla/Documents/GitHub/external-adapters-js/.pnp.cjs:42492:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/jvilla/Documents/GitHub/external-adapters-js/packages/core/bootstrap/dist/index.js:6:17)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
The README mentions that some require environmental variables, but I don't see anything mentioned in coingecko and I'm not having any luck with the other adapters either.
Thanks to help in the Discord, I was able to resolve my issue. I was using an old version of node and needed to upgrade! The separate, but related, Chainlink Node Operator repo README has Node v12 hardcoded in its setup process, which won't work when running the External Adapter repo.

Truffle Drizzle Tutorial fails on last step 'npm run dev'

I am on windows 10, using vscode. Basically finished the petshop tutorial with no issues or problems using truffle.
when I enter the command npm run dev it fails as shown below.
PS Y:\code\petshop> npm run dev
> pet-shop#1.0.0 dev
> lite-server
internal/modules/cjs/loader.js:316
throw err;
^
Error: Cannot find module 'Y:\code\petshop\node_modules\immutable\dist\immutable'. Please verify that the package.json has a valid "main" entry
at tryPackage (internal/modules/cjs/loader.js:308:19)
at Function.Module._findPath (internal/modules/cjs/loader.js:521:18)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:872:27)
at Function.Module._load (internal/modules/cjs/loader.js:730:27)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (Y:\code\petshop\node_modules\browser-sync\dist\hooks.js:3:17)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32) {
code: 'MODULE_NOT_FOUND',
path: 'Y:\\code\\petshop\\node_modules\\immutable\\package.json',
requestPath: 'immutable'
}
Not sure where to go from here, nothing works. This type of error is a bit beyond me. Any and all help is greatly appreciated.
EDIT: changed screenshot to code snippet. And I realized the problem is that the 'immutable' path is non-existent in my node_modules. Still not sure how to address this. tried a cheeky npm install immutable to no avail....

Lerna command in AWS Codebuild

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.

Too many errors

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.

Resources