Error: Can't find module 'express'

#1

I am getting this error:

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. (/app/server.js:2:17)
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)

#2

Can you try using the following commands in your console?

$ rm shrinkwrap.yaml
$ enable.pnpm
1 Like
#3

The error is still there

#4

Can I be invited to the project!

1 Like
#5

Hey @SWP360, the second command that @Callum-OKane asked you to run has a typo - it should be enable-pnpm. Can you give that a try in your project’s console?

1 Like
#6

@cori

I am in the project right now, and I have tried both of these,and there does not seem to be a shrinkwrap.yaml at all. Can you take a closer look?

valiant-flax

1 Like
#7

My guess is that this is due to a faulty item in your package.json’s dependencies node. I’m seeing this in there:

    "random-puppy": "^1.1.0",
    "reques": "^1000.0.0",
    "request": "^2.88.0",

I think the middle one of those doesn’t exist, or at least not at that version, and so is causing the package install step to fail. Express happens to be the first thing that’s not installed properly that Node tries to get to, so that’s where the problem shows up.

@SWP360 can you remove that line (or correct it if it’s just a typo) and let us know where that gets you?

1 Like
#8

Error: Cannot find module ‘pokemon-gif’ :thinking:

#9

One way to track stuff like this down is to run the enable-pnpm command in your project’s console and then to flip back to the Logs pane right away. That will show you the messages from the install process as they happen before they get pushed off the screen by project error messages like this one.

Often in those messages you can see errors that might help lead you to whatever’s really wrong (which is very often not what the project’s error messages are telling you, since they just point to a symptom, not to a cause). In the previous case you’d have seen a message that indicated that there was no version 1000 for package reques. You can also open the console and type pnpm i -v and not flip back to the logs - that will show the same sorts of messages but they won’t get pushed off screen by project errors.

@SWP360 can you do one of those two things and let us know what messages you see?

1 Like
#10

No matching version found for pokemon-gif@>=1.1.0 <2.0.0

#11

Ok! That’s useful!

Now if you look at the versions tab of https://www.npmjs.com/package/pokemon-gif you’ll see that the latest released version is 1.0.14, so the version you’re expecting in your package.json doesn’t exist.

My guess (without doing a ton of digging) is that you used the package.json Update Package button and updated that package to what Glitch tells you is the most up-to-date version. We rely on a service called libraries.io for this information, and their entry for this package is out of date, I suspect because there was a 1.1.0 version that has since been unpublished and they haven’t updated their information yet, so when you upgraded your package,json file it broke on that incorrect information.

If you fix the version for that package to ^1.0.14 I think that’ll fix this issue. If you run into other problems of this nature then similar fixes for those packages should fix those errors.

2 Likes