Watcher error and node modules cannot be found on Heroku deployment

Hi, I am using Botpress 11.5 and deployed using the heroku method as documented. However, as I look into the logs, I realise there’s this error:

Watcher error [Error, ENOSPC: no space left on device, watch '/botpress/data/bots/mock/actions/node_modules/node-sp-auth/lib/src/auth/resolvers/OnpremiseUserCredentials.d.ts']
STACK TRACE
Error: ENOSPC: no space left on device, watch '/botpress/data/bots/mock/actions/node_modules/node-sp-auth/lib/src/auth/resolvers/OnpremiseUserCredentials.d.ts'
    at FSWatcher.start (fs.js:1409:26)
    at Object.fs.watch (fs.js:1446:11)
    at createFsWatchInstance (/snapshot/build-linux/node_modules/chokidar/lib/nodefs-handler.js:38:15)
    at setFsWatchListener (/snapshot/build-linux/node_modules/chokidar/lib/nodefs-handler.js:81:15)
    at FSWatcher.NodeFsHandler._watchWithNodeFs (/snapshot/build-linux/node_modules/chokidar/lib/nodefs-handler.js:233:14)
    at FSWatcher.NodeFsHandler._handleFile (/snapshot/build-linux/node_modules/chokidar/lib/nodefs-handler.js:262:21)
    at FSWatcher.<anonymous> (/snapshot/build-linux/node_modules/chokidar/lib/nodefs-handler.js:495:21)
    at FSReqWrap.oncomplete (fs.js:185:5)

It happens for a lot of the node modules (a thousand rows in the Postgres database). Also, not sure whether it is because of this, but one of my modules I used in my actions cannot be found despite the node_modules folder being present in the “actions” folders:

An error occurred while executing the action "integratedUpload [Error, Module "spsave" not found. Tried these locations: "/botpress/data/bots/mock/actions"]
STACK TRACE
Error: Module "spsave" not found. Tried these locations: "/botpress/data/bots/mock/actions"
    at Object.exports.requireAtPaths (/snapshot/build-linux/out/bp/core/modules/require.js:0:0)
    at _prepareRequire.module (/snapshot/build-linux/out/bp/core/services/action/action-service.js:0:0)
    at Object.get (/snapshot/build-linux/out/bp/core/services/action/action-service.js:0:0)
    at _require (/snapshot/build-linux/node_modules/vm2/lib/sandbox.js:190:58)
    at Object.<anonymous> (vm.js:5:16)
    at NodeVM.run (/snapshot/build-linux/node_modules/vm2/lib/main.js:428:23)
    at runInVm.Promise (/snapshot/build-linux/out/bp/core/services/action/vm.js:0:0)
    at Promise._execute (/botpress/modules/.cache/module__14bd811da0c953338c50b79fd7487a79e237cedbbae44b6835a7085a226cf539/node_production_modules/bluebird/js/release/debuggability.js:313:9)
    at Promise._resolveFromExecutor (/botpress/modules/.cache/module__14bd811da0c953338c50b79fd7487a79e237cedbbae44b6835a7085a226cf539/node_production_modules/bluebird/js/release/promise.js:488:18)
    at new Promise (/botpress/modules/.cache/module__14bd811da0c953338c50b79fd7487a79e237cedbbae44b6835a7085a226cf539/node_production_modules/bluebird/js/release/promise.js:79:10)
    at VmRunner.runInVm (/snapshot/build-linux/out/bp/core/services/action/vm.js:0:0)
    at ScopedActionService.<anonymous> (/snapshot/build-linux/out/bp/core/services/action/action-service.js:0:0)
    at Generator.next (<anonymous>)
    at fulfilled (/snapshot/build-linux/out/bp/core/services/action/action-service.js:0:0)
    at tryCatcher (/botpress/modules/.cache/module__14bd811da0c953338c50b79fd7487a79e237cedbbae44b6835a7085a226cf539/node_production_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/botpress/modules/.cache/module__14bd811da0c953338c50b79fd7487a79e237cedbbae44b6835a7085a226cf539/node_production_modules/bluebird/js/release/promise.js:517:31)
    at Promise._settlePromise (/botpress/modules/.cache/module__14bd811da0c953338c50b79fd7487a79e237cedbbae44b6835a7085a226cf539/node_production_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromiseCtx (/botpress/modules/.cache/module__14bd811da0c953338c50b79fd7487a79e237cedbbae44b6835a7085a226cf539/node_production_modules/bluebird/js/release/promise.js:611:10)
    at _drainQueueStep (/botpress/modules/.cache/module__14bd811da0c953338c50b79fd7487a79e237cedbbae44b6835a7085a226cf539/node_production_modules/bluebird/js/release/async.js:142:12)
    at _drainQueue (/botpress/modules/.cache/module__14bd811da0c953338c50b79fd7487a79e237cedbbae44b6835a7085a226cf539/node_production_modules/bluebird/js/release/async.js:131:9)
    at Async._drainQueues (/botpress/modules/.cache/module__14bd811da0c953338c50b79fd7487a79e237cedbbae44b6835a7085a226cf539/node_production_modules/bluebird/js/release/async.js:147:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/botpress/modules/.cache/module__14bd811da0c953338c50b79fd7487a79e237cedbbae44b6835a7085a226cf539/node_production_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:696:18)
    at tryOnImmediate (timers.js:667:5)
    at processImmediate (timers.js:649:5)
    at process.topLevelDomainCallback (domain.js:121:23)

There are a lot of files (7000) in the node_modules folder as the main few modules I am using has a lot of dependencies which I suspect may be the cause. Any ideas on how to fix this issue or if later versions of Botpress will resolve this?

I tried deploying using Dokku instead and ran into the same CacheInvalidator and Watcher error but to solve it I did this:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

then
sysctl --system
and the issue was gone.

However, on Dokku, I encountered other issues which were even more serious which is the bot does not even respond. The Chrome console shows that the bot fails to get the resource as shown below:

What is the issue? Thanks in advance for any help!

The issue was solved when I changed to an EC2 instance with a bigger RAM.