Cannot find module "express"

module.js:550

throw err;

^


Error: Cannot find module 'express'

at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/app/server.js:5:16)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)

I’m getting this error since two days and without the server.js the bot is working properly. Any ideas how to fix it?

Hey @BullDogBg, this often means that there’s a problem somewhere in your package.json or dependencies that disrupts the pnpm install process. Express never actually gets installed, and it’s the first package that’s required in your code path, so Node throws an error when trying to find it - in other words it has nothingh to do with Express directly; that’s just the first problem your project encounters.

Running pnpm-install or its close mat enable-pnpm in your project’s console (see https://support-assets.glitch.me/logs-pane-console for how to get there if you don’t know how) and watching the output can often show you the actual source of the problem. If you want to share your project name someone can take a closer look.

Hey @cori, can you take a look because I’ve lost the thread? I’ll DM you an link if you want.

Sure. I just need the project name (some Glitch staff can view private projects when requested to).

Thank you, It’s the-clashers-bot.

Hey @BullDogBg I was able to resolve the issue in a remix of your project by running enable-pnpm in the console. This forces a full reinstall of all the modules. Have you tried that yet?

2 Likes

No, but I’ll try. Thank you very much!

1 Like

Yes everything is OK now. Thank you again!

1 Like

@cori 2 weeks later same problem, but with the better-sqlite3 module. I’ve tried enable-pnpm, refresh and reinstalling the module but nothing helped. Without the const requiring it works.

Hey @BullDogBg I think this problem might be related to the fact that you have node called out in your dependencies. I’d suggest trying removing that dependency and then running enable-pnpm again to see if that clears things up. You don’t need to declare node as a dependency, and sometimes doing so results in (p)npm trying to resolve other dependencies inside the node folder created in the pnpm volume instead of in the right spot.

If you need a specific version of node, the correct spot to place that is in the engines section just below your dependencies.

Hello, I am getting this exact error once again but a new problem. The terminal refuses to start, including the full page one. “failed to start terminal”. I cannot do anything with the project, remixing does not work either.

1 Like

The fail to start terminal error is a glitch bug, you should contact them about it at support@glitch.com

I have the same problem

1 Like

Contact glitch support at support@glitch.com or view the status page at status.glitch.com.

I am having same problem it just started and I did not change anything.

2 Likes