Task runners fail to start module

Describe the problem/error/question

I added environment variable N8N_RUNNERS_ENABLED=true after version 1.80 due a deployment message regarding it. Since then, I started having an error of task runner startup, below. It says, the module moment_with_locales, already defined on environment variable NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash,moment-with-locales,bcrypt, cannot be found. It means, even if the modules may be installed, they are not reachable.

What is the error message (if any)?

[Task Runner]: Task runner failed to start {
  error: Error: Cannot find module 'moment-with-locales'
  Require stack:
  - /usr/local/lib/node_modules/n8n/node_modules/@n8n/task-runner/dist/js-task-runner/js-task-runner.js
  - /usr/local/lib/node_modules/n8n/node_modules/@n8n/task-runner/dist/start.js
      at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
      at Module._load (node:internal/modules/cjs/loader:1051:27)
      at Module.require (node:internal/modules/cjs/loader:1311:19)
      at require (node:internal/modules/helpers:179:18)
      at JsTaskRunner.preventPrototypePollution (/usr/local/lib/node_modules/n8n/node_modules/@n8n/task-runner/dist/js-task-runner/js-task-runner.js:86:17)
      at new JsTaskRunner (/usr/local/lib/node_modules/n8n/node_modules/@n8n/task-runner/dist/js-task-runner/js-task-runner.js:81:14)
      at start (/usr/local/lib/node_modules/n8n/node_modules/@n8n/task-runner/dist/start.js:85:14)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
      '/usr/local/lib/node_modules/n8n/node_modules/@n8n/task-runner/dist/js-task-runner/js-task-runner.js',
      '/usr/local/lib/node_modules/n8n/node_modules/@n8n/task-runner/dist/start.js'
    ]
  }

Information on your n8n setup

  • n8nVersion: 1.81.4
  • platform: docker (self-hosted)
  • nodeJsVersion: 20.18.3
  • database: postgres
  • executionMode: scaling
  • concurrency: 20
  • license: enterprise (production)
  • consumerId: 4aa69540-a99f-4c7c-b855-1cd14bda25cd
  • n8nVersion: 1.82.3
  • platform: docker (self-hosted)
N8N_RUNNERS_ENABLED=True
NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash,moment-with-locales

[Task Runner]: Task runner failed to start {
  error: Error: Cannot find module 'moment-with-locales'
  Require stack:
  - /usr/local/lib/node_modules/n8n/node_modules/@n8n/task-runner/dist/js-task-runner/js-task-runner.js
  - /usr/local/lib/node_modules/n8n/node_modules/@n8n/task-runner/dist/start.js
      at Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
      at Module._load (node:internal/modules/cjs/loader:1051:27)
      at Module.require (node:internal/modules/cjs/loader:1311:19)
      at require (node:internal/modules/helpers:179:18)
      at JsTaskRunner.preventPrototypePollution (/usr/local/lib/node_modules/n8n/node_modules/@n8n/task-runner/dist/js-task-runner/js-task-runner.js:86:17)
      at new JsTaskRunner (/usr/local/lib/node_modules/n8n/node_modules/@n8n/task-runner/dist/js-task-runner/js-task-runner.js:81:14)
      at start (/usr/local/lib/node_modules/n8n/node_modules/@n8n/task-runner/dist/start.js:85:14)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
      '/usr/local/lib/node_modules/n8n/node_modules/@n8n/task-runner/dist/js-task-runner/js-task-runner.js',
      '/usr/local/lib/node_modules/n8n/node_modules/@n8n/task-runner/dist/start.js'
    ]
  }

after my attempt to add the missed moment-with-locales:

pm error 404 Not Found - GET https://registry.npmjs.org/moment-with-locales - Not found
npm error 404
npm error 404  'moment-with-locales@*' is not in this registry.

The package moment-with-locales no longer exists in the npm registry.
As of Moment.js version 2.13.0, all locales have been included in the main moment package. Therefore, you no longer need to install moment-with-locales separately.

So, update our configuration by removing moment-with-locales from your NODE_FUNCTION_ALLOW_EXTERNAL

1 Like

How did you do that? Same issue here.

Remove module ‘moment-with-locales’ from all services and you are good to go.