N8n: Permission denied when running NPM install command in Docker container

Describe the issue/error/question

Objective: Install uuid library for Node, so I can generate UUIDs with a

I am running n8n using the n8nio/n8n:latest-debian container image on an ODROID M1 (arm64) with Ubuntu Server 22.04 LTS. I used the Docker Engine to run the n8n container.

After creating an account and logging in, I tried to create a Command node that runs npm install --global uuid.

Unfortunately, I am getting a permissions error, saying that I can’t install the module. Any ideas why this error is happening? I tried switching from the latest container image to the latest-debian image, but that didn’t change anything.

What is the error message (if any)?

Problem in node ‘Execute Command‘
Command failed: npm install --global uuid npm ERR! code EACCES npm ERR! syscall mkdir npm ERR! path /usr/local/lib/node_modules/uuid npm ERR! errno -13 npm ERR! Error: EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules/uuid’ npm ERR! [Error: EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules/uuid’] { npm ERR! errno: -13, npm ERR! code: ‘EACCES’, npm ERR! syscall: ‘mkdir’, npm ERR! path: ‘/usr/local/lib/node_modules/uuid’ npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It is likely you do not have the permissions to access this file as the current user npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! A complete log of this run can be found in: npm ERR! /home/node/.npm/_logs/2023-03-16T22_15_46_687Z-debug-0.log

Please share the workflow

Share the output returned by the last node

N/A

Information on your n8n setup

  • n8n version: latest
  • Database you’re using (default: SQLite): SQLite
  • Running n8n with the execution process [own(default), main]: default
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker

Hey @trevor,

If you want to add packages to the docker image the best way is to use a custom image the user n8n runs as in the container doesn’t have access to add new packages and when you upgrade the package would be removed.

If it helps uuids can be created using the crypto node, the uuid package is also something that is already used by n8n so if you set the env option below you should be able to use it from a code node.

NODE_FUNCTION_ALLOW_EXTERNAL=uuid

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.