Cannot find module - Node error


So I have a basic Discord bot hosted on Glitch. Been working perfectly fine for the last couple of weeks, however this morning I started getting the following error in the console:

    throw err;
Error: Cannot find module 'node-fetch'
Require stack:
- /app/server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:610:15)
    at Function.Module._load (internal/modules/cjs/loader.js:526:27)
    at Module.require (internal/modules/cjs/loader.js:666:19)
    at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (/app/server.js:1:15)
    at Module._compile (internal/modules/cjs/loader.js:759:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
    at Module.load (internal/modules/cjs/loader.js:628:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:826:10)

where Node seems unable to load any of the modules. Here’s my package.json:

  "//1": "describes your app and its dependencies",
  "//2": "",
  "//3": "updating this file will download and update your packages",
  "name": "hello-express",
  "version": "0.0.1",
  "description": "A simple Node app built on Express, instantly up and running.",
  "main": "server.js",
  "scripts": {
    "start": "node server.js"
  "dependencies": {
    "express": "^4.17.1",
    "discord.js": "^11.5.1",
    "node-fetch": "^2.6.0",
    "sqlite": "^3.0.3"
  "engines": {
    "node": "12.x"
  "repository": {
    "url": "!/hello-express"
  "license": "MIT",
  "keywords": [

Any help would be much appreciated. Thanks!

Hey @RalphHarrison,

Can you try running enable-pnpm in the console?

Hope this helps!

Tried that, the error message changed to something about “disk space”.

However, I just checked my bot again half an hour ago and it seems to be online again, after a “Initializing node_modules, hold on…” message in the console. Seems to be working fine, but would appreciate it if I knew how to fix this in the future. Thanks for the help!

1 Like