NealSr
August 24, 2023, 4:31pm
1
Describe the problem/error/question
I was able to pull in request-promise-native in the past on v.0.222.1 but after migrating to 1.1.1 I am getting errors trying to pull it in as a dependency in a code node. I’m sure it is something simple but I’ve tried quite a few variations based on the environment variables guide.
What is the error message (if any)?
ERROR: Cannot find module 'request-promise-native' [Line 1 | Item Index: 0]
Folder Structure
ubuntu@ip-address:~/n8n-docker$ ls /home/ubuntu/n8n-docker/node_modules/
lodash psl punycode request-promise-core request-promise-native stealthy-require tough-cookie
ubuntu@ip-address:~/n8n-docker$ ls -alh /home/ubuntu/.n8n/custom/node_modules/
total 8.0K
drwxr-xr-x 2 ubuntu ubuntu 4.0K Aug 24 16:00 .
drwxrwxr-x 3 ubuntu ubuntu 4.0K Aug 24 16:00 ..
lrwxrwxrwx 1 ubuntu ubuntu 43 Aug 24 16:00 request -> ../../../../../usr/lib/node_modules/request
lrwxrwxrwx 1 ubuntu ubuntu 58 Aug 24 16:00 request-promise-native -> ../../../../../usr/lib/node_modules/request-promise-native
Workflow
docker-compose file environment variables
environment:
- N8N_BASIC_AUTH_ACTIVE=false
- N8N_HOST=n8n.domain.com
- N8N_PORT=5678
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_URL=https://n8n.domain.com/
- GENERIC_TIMEZONE=America/New_York
- N8N_CUSTOM_EXTENSIONS=/home/ubuntu/n8n-docker/node_modules
- NODE_FUNCTION_ALLOW_BUILTIN=*
- NODE_FUNCTION_ALLOW_EXTERNAL=request-promise-native,jsonwebtoken,axios,querystring,form-data,moment
- NODE_OPTIONS=--max-old-space-size=4096
- EXECUTIONS_PROCESS=main
- DB_SQLITE_VACUUM_ON_STARTUP=true
- EXECUTIONS_DATA_PRUNE=true
- EXECUTIONS_DATA_MAX_AGE=720
volumes:
- ${DATA_FOLDER}/.n8n:/home/node/.n8n
- ${DATA_FOLDER}/local-files:/n8n-local-files
Information on your n8n setup
n8n version: 1.1.1
Database (default: SQLite): SQLite
n8n EXECUTIONS_PROCESS setting (default: own, main): main
Running n8n via (Docker, npm, n8n cloud, desktop app): docker-compose
Operating system: ubuntu
NealSr
August 24, 2023, 5:53pm
2
Some additional info:
I was able to get past the error by mounting a volume for each and every directory in node_modules, but that doesn’t seem sustainable. Is that the only way to import external modules in n8n 1.x ?
volumes:
- ${DATA_FOLDER}/.n8n:/home/node/.n8n
- ${DATA_FOLDER}/local-files:/n8n-local-files
- ~/.n8n/custom/node_modules/252K:/usr/local/lib/node_modules/252K
- ~/.n8n/custom/node_modules/.bin:/usr/local/lib/node_modules/.bin
- ~/.n8n/custom/node_modules/.package-lock.json:/usr/local/lib/node_modules/.package-lock.json
- ~/.n8n/custom/node_modules/ajv:/usr/local/lib/node_modules/ajv
- ~/.n8n/custom/node_modules/asn1:/usr/local/lib/node_modules/asn1
- ~/.n8n/custom/node_modules/assert-plus:/usr/local/lib/node_modules/assert-plus
- ~/.n8n/custom/node_modules/asynckit:/usr/local/lib/node_modules/asynckit
- ~/.n8n/custom/node_modules/aws-sign2:/usr/local/lib/node_modules/aws-sign2
- ~/.n8n/custom/node_modules/aws4:/usr/local/lib/node_modules/aws4
- ~/.n8n/custom/node_modules/bcrypt-pbkdf:/usr/local/lib/node_modules/bcrypt-pbkdf
- ~/.n8n/custom/node_modules/caseless:/usr/local/lib/node_modules/caseless
- ~/.n8n/custom/node_modules/combined-stream:/usr/local/lib/node_modules/combined-stream
- ~/.n8n/custom/node_modules/core-util-is:/usr/local/lib/node_modules/core-util-is
- ~/.n8n/custom/node_modules/dashdash:/usr/local/lib/node_modules/dashdash
- ~/.n8n/custom/node_modules/delayed-stream:/usr/local/lib/node_modules/delayed-stream
- ~/.n8n/custom/node_modules/ecc-jsbn:/usr/local/lib/node_modules/ecc-jsbn
- ... ... ...
- ... ... ...
- ~/.n8n/custom/node_modules/verror:/usr/local/lib/node_modules/verror
This is unfortunately expected @NealSr as with v1 n8n will no longer load custom nodes (and other modules) from its global node_modules
directory (n8n v1.0 migration guide | n8n Docs ).
Based on the compose config you have shared it seems to me you could simplify things by mounting your entire /usr/local/lib/node_modules
directory rather than the individual modules (though I haven’t tried this first hand):
volumes:
- ${DATA_FOLDER}/.n8n:/home/node/.n8n
- ${DATA_FOLDER}/local-files:/n8n-local-files
- ~/.n8n/custom/node_modules:/usr/local/lib/node_modules
Perhaps you want to give this a go?
1 Like
system
Closed
November 27, 2023, 7:12am
5
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.