Continuously getting "cannot find module" error

Creating a Discord bot with a few modules. Using npm to be able to edit files in certain node modules.

This has always been working in the past, but for some reason I am getting the error “cannot find module” all of a sudden. The error is in a node module that I had edited requiring a json file outside of the module.

Again, it has been working in the past and had suddenly stopped working. I’ve tried going from pnpm to npm and resetting it, but I am still getting the error.


1 Like

Hey @kevinb02 can you please provide your project name so someone can take a closer look?

Project name is “envisionbot40”

It could possibly be an issue when the project changes hosts maybe?

If you try running ls in the console does it list the JSON file?

Also, if you are repeatedly reading/writing from/to the JSON then your Discord bot will degrade in performance. I’d suggest you use a database like SQLite instead.

EDIT: Spelling.

Yes; when I ran ls, all the JSON files are there.

I’m not sure if it would be a changing host problem because it has worked fine in the past.

Strange, was your last host running Windows by any chance as it could be an issue with the way Linux paths work compared to Windows’. However, I doubt that caused the problem.

I’m thinking that the module/file may be looking in the wrong directory for the file.

If your passing the file as an argument then use: somefunction( "/app/somejsonfile.json")

If you could send a full screenshot of the error or copy and paste the error.

Hey @kevinb02 I’m not seeing any errors regarding edited node modules (or errors related to node modules at all) right now, so I’m not sure what I should be looking for.

Perhaps if you can reproduce the error you mentioned to start again you can post the full error details?

Changed it to /app/file.json instead of ../../.././file.json and it worked. Thanks so much!