Error: Cannot find module 'Canvas'

Project name: https://glitch.com/~poke-isles - you probably won’t be able to load this as it is very large.
My bot works perfectly, but when I try to use a command that requires Canvas, I get the Error: Cannot find module 'Canvas' error.
I’ve tried rm -rf node_modules but that doesn’t seem to do anything. I’ve also tried npm i which seems to work without any errors.

Can you provide a full error text?

Have you tried npm i canvas -s?
Or, if it requires to build, have you tried node-gyp rebuild in canvas folder?

If it’s pushing the upper-limit of how much space a project can take up, it might lead to errors like these. Behavior seems to get unpredictable as projects fill up.

The container status seems to be alright. I’m only just using a 10th of the available space.

Cannot find module 'Canvas'5:42 PM

at Function.Module._resolveFilename (module.js:548:15)5:42 PM

at Function.Module._load (module.js:475:25)5:42 PM

at Module.require (module.js:597:17)5:42 PM

at require (internal/module.js:11:18)

I just tried npm I canvas and nothing seems to have changed.
I don’t know how to use node-gyp rebuild

Hmm…I think I’ve seen similar issues resolved by running rm -rf shrinkwrap.yaml && enable-pnpm. It’s also possible that there’s a separate issue with another (such as a deprecated and 404’ing dependency elsewhere in the package.json) which is causing other dependencies not to install.

I tried that, still the same error. I doubt that it’s related to the package, but here it is.

{
  "name": "poke-isles",
  "version": "1.0.0",
  "description": "A PokeBot that's based on fields of Pokemon, rather than spamming to spawn them.",
  "main": "bot.js",
  "scripts": {
    "start": "node bot.js"
  },
  "engines": {
    "node": "8.4.0"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/MegaAura/pokebot.git"
  },
  "keywords": [
    "bot",
    "discord",
    "pokemon"
  ],
  "author": "Aura",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/MegaAura/pokebot/issues"
  },
  "homepage": "https://github.com/MegaAura/pokebot#readme",
  "dependencies": {
    "canvas": "^2.6.1",
    "discord.js": "^11.5.1",
    "enmap": "^5.2.0",
    "express": "^4.16.4"
  }
}

Hm…I’ll need to dig into the packages more but maybe they’re expecting a later version of node. Have you tried changing the node version to 10? I’d also be happy to tinker with it in place if you want to DM me an invite?

Yeah that could be it. I’ll send it to you now.

Hey @Aura it looks to me like this is currently reasolved; a missing package like this often means there was a temporary installation issue and re-running enable-pnpm (sometime after deleting shrinkwrap.yaml) is often enough to get things running properly again.

Please let us know if you’re still having issues!

How would I delete shrinkwrap.yaml? I’ve seen it when I’ve exported to GitHub before.
Also, this issue has been resolved.