Ask coding questions

← Back to all posts
Problems with not able to find module 'express'
LukeZeller (3)

I've been having a problem where whenever my repl wakes up, it throws this error:

    throw err;

Error: Cannot find module 'express'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
    at Function.Module._load (internal/modules/cjs/loader.js:475:25)
    at Module.require (internal/modules/cjs/loader.js:598:17)
    at require (internal/modules/cjs/helpers.js:11:18)
    at Object.<anonymous> (/home/runner/index.js:1:77)
    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)
exit status 1

The way I've found to fix it is to rename package.json to something else, start the repl, fix the name of package.json, and restart the repl.
Is there a fix on the way? Or a better way to do this?

eankeen (1043)


page refreshes typically fix most common miscellaneous bugs. if that doesn't work, then navigating to the "my repls" screen, refreshing, then navigating back to your repl usually fixes some bugs. kind of strange because i've never come across an error like that.

hope i could help :)

turbio (59)

It looks like your package has an invalid name according to npm's docs. We use npm under the hood to install packages so if npm rejects your package.json we won't be able to install anything.

LukeZeller (3)

@turbio the package in question was installed automatically, and when i rename the pacakge.json file, the package works fine.