Install googleapis successfully but couldnt import it

I am trying to use the Google API (@googleapis/androidpublisher) module in a Code node inside my n8n workflow. Although I have installed the module and tested it successfully inside the Docker container, n8n is unable to recognize the module when the workflow is executed. The same error occurs for other modules like jsonwebtoken unless NODE_FUNCTION_ALLOW_EXTERNAL=* is set, but even that doesn’t work consistently.

Cannot find module ‘@googleapis/androidpublisher’ [line 1]

Below is the workflow I am testing with:

  • n8n version: 1.72.1
  • Database: SQLite
  • n8n EXECUTIONS_PROCESS setting: Default (own)
  • Running n8n via: Docker (self-hosted)
  • Operating system: macOS (host machine)

What I’ve tried so far:
Installed @googleapis/androidpublisher inside the Docker container in /home/node/.n8n/node_modules

npm install @googleapis/androidpublisher --prefix /home/node/.n8n

node -e “require(‘@googleapis/androidpublisher’); console.log(‘Module loaded successfully!’)”

This works successfully.

ln -s /home/node/.n8n/node_modules/@googleapis /usr/local/lib/node_modules/@googleapis


chmod -R 755 /home/node/.n8n/node_modules
chmod -R 755 /usr/local/lib/node_modules

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:
  • n8n version: 1.72.1
  • Database: SQLite
  • n8n EXECUTIONS_PROCESS setting: Default (own)
  • Running n8n via: Docker (self-hosted)
  • Operating system: macOS (host machine)

I have a similar problem: I added several libraries by building a docker container. It used to work, but after an upgrade, the libraries are no longer available…

Here is the Dockerfile:

FROM n8nio/n8n:1.73.1
USER root
RUN apk update && apk upgrade &&  apk add graphicsmagick inkscape qpdf imagemagick
USER node
RUN npm install bcrypt body-parser ovh googleapis

and the docker-compose.yml:

version: '2'

services:
  n8n:
    build:
      context: .
    container_name: n8n_test    
    environment:
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - NODE_PATH=/home/node/node_modules
      - GENERIC_TIMEZONE=Europe/Paris
      - NODE_FUNCTION_ALLOW_BUILTIN=*
      - NODE_FUNCTION_ALLOW_EXTERNAL=bcrypt,body-parser,googleapis,lodash,moment,ovh,ua-parser-js

with n8n version 1.43 the modules were available, when upgrading to 1.73, they are not anymore.

OK I think I found a way to make it work: use user root instead of user node :-/

So the Dockefile becomes (note the -g for npm install):

FROM n8nio/n8n:1.73.1
USER root
RUN npm install -g bcrypt body-parser ovh googleapis --force --legacy-peer-deps
USER node

I’m not a Docker guru but I feel this is less safe than the previous version, however it seems to work.

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