Using handlebars.js
-
I would like activate handelbars (an extension to the Mustache templating language) for Function-nodes so I've had this line in
/app/data/.envexport NODE_FUNCTION_ALLOW_EXTERNAL=handlebarsbut, it doesn't work when I execute my workflow, I have this error
"Cannot find module 'handlebars'" -
I would like activate handelbars (an extension to the Mustache templating language) for Function-nodes so I've had this line in
/app/data/.envexport NODE_FUNCTION_ALLOW_EXTERNAL=handlebarsbut, it doesn't work when I execute my workflow, I have this error
"Cannot find module 'handlebars'" -
The package already has
N8N_CUSTOM_EXTENSIONS="/app/data/custom"though I don't know if this means that a user cannpm install handlebarsin that directory and use it. Maybe @BrutalBirdie knows. -
@girish Got no clue either

Will have to take a look at it.@brutalbirdie looks like
N8N_CUSTOM_EXTENSIONSis for custom nodes - https://docs.n8n.io/getting-started/installation/advanced/configuration.html#examples and not for custom node modules -
@brutalbirdie looks like
N8N_CUSTOM_EXTENSIONSis for custom nodes - https://docs.n8n.io/getting-started/installation/advanced/configuration.html#examples and not for custom node modulesthanks to all, I am a newbe with n8n
@girish @BrutalBirdie this doc indicate that for security reasons, importing modules is restricted by default in the Function-Nodes and that it is possible to lift that restriction by setting the following environment variables:
- NODE_FUNCTION_ALLOW_BUILTIN: For builtin modules
- NODE_FUNCTION_ALLOW_EXTERNAL: For external modules sourced from
n8n/node_modulesdirectory
So I created a
node_modulesdirectory in/app/data/and installed in it the module handlebars with the commandnpm install handlebarsbut it doesn't work. I also tried in/app/data/.n8ndirectory with the same result. -
thanks to all, I am a newbe with n8n
@girish @BrutalBirdie this doc indicate that for security reasons, importing modules is restricted by default in the Function-Nodes and that it is possible to lift that restriction by setting the following environment variables:
- NODE_FUNCTION_ALLOW_BUILTIN: For builtin modules
- NODE_FUNCTION_ALLOW_EXTERNAL: For external modules sourced from
n8n/node_modulesdirectory
So I created a
node_modulesdirectory in/app/data/and installed in it the module handlebars with the commandnpm install handlebarsbut it doesn't work. I also tried in/app/data/.n8ndirectory with the same result. -
@jeau I think the module has to be installed in the docker image itself. Is there a way to not use handlebars? Just curious why it's needed. Maybe we can add it to the n8n image itself.
@girish you can read this discussion https://community.n8n.io/t/text-templating-node/1965
handelbars is a template system to facilitate the creation of html document pages, https://handlebarsjs.com/
in my case, I want to get information from baserow tables and use n8n to generate reports and send them by mails
-
@girish you can read this discussion https://community.n8n.io/t/text-templating-node/1965
handelbars is a template system to facilitate the creation of html document pages, https://handlebarsjs.com/
in my case, I want to get information from baserow tables and use n8n to generate reports and send them by mails
@jeau there is a env var
NODE_PATHthat tells node where to find additional node modules. So, you can set the variable in/app/data/envlikeNODE_PATH=/app/data/modulesand then in Web Terminal:mkdir /app/data/modules cd /app/data/modules npm install handlebarsRestart the app afterwards.
-
@jeau there is a env var
NODE_PATHthat tells node where to find additional node modules. So, you can set the variable in/app/data/envlikeNODE_PATH=/app/data/modulesand then in Web Terminal:mkdir /app/data/modules cd /app/data/modules npm install handlebarsRestart the app afterwards.
@girish thanks, however I have this errors after passing the command
npm install handlebarsnpm ERR! code EROFS npm ERR! syscall open npm ERR! path /root/.npm/_cacache/tmp/2122bb8f npm ERR! errno -30 npm ERR! rofs EROFS: read-only file system, open '/root/.npm/_cacache/tmp/2122bb8f' npm ERR! rofs Often virtualized file systems, or other file systems npm ERR! rofs that don't support symlinks, give this error.I tried
npm install --prefix /app/data/modules handlebarsbut the result was the samehowever, I have already successfully installed handelbars before, but I forgot how to do it

-
@girish thanks, however I have this errors after passing the command
npm install handlebarsnpm ERR! code EROFS npm ERR! syscall open npm ERR! path /root/.npm/_cacache/tmp/2122bb8f npm ERR! errno -30 npm ERR! rofs EROFS: read-only file system, open '/root/.npm/_cacache/tmp/2122bb8f' npm ERR! rofs Often virtualized file systems, or other file systems npm ERR! rofs that don't support symlinks, give this error.I tried
npm install --prefix /app/data/modules handlebarsbut the result was the samehowever, I have already successfully installed handelbars before, but I forgot how to do it

-
@girish thanks, however I have this errors after passing the command
npm install handlebarsnpm ERR! code EROFS npm ERR! syscall open npm ERR! path /root/.npm/_cacache/tmp/2122bb8f npm ERR! errno -30 npm ERR! rofs EROFS: read-only file system, open '/root/.npm/_cacache/tmp/2122bb8f' npm ERR! rofs Often virtualized file systems, or other file systems npm ERR! rofs that don't support symlinks, give this error.I tried
npm install --prefix /app/data/modules handlebarsbut the result was the samehowever, I have already successfully installed handelbars before, but I forgot how to do it

-
@jeau I can fix that . Can you try
npm install handlebars --cache /tmp/fooin the meantime ?@girish I went back to a fresh installation, because I had not checked the changes of the recent updates. This fix allows me to install handelbars. But it still doesn't work, I still get the message
Cannot find module 'handlebars'with this example.My session:
root@XYZ:/app/data# vi env root@XYZ:/app/data# cat env # Set the logging level to 'debug' export EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=true export EXECUTIONS_DATA_SAVE_ON_ERROR=all export EXECUTIONS_DATA_SAVE_ON_SUCCESS=all export N8N_LOG_LEVEL=info export NODE_PATH=/app/data/modules export NODE_FUNCTION_ALLOW_EXTERNAL=handlebars root@XYZ:/app/data# mkdir modules root@XYZ:/app/data# cd /app/data/modules root@XYZ:/app/data/modules# npm install handlebars --cache /tmp/foo npm WARN saveError ENOENT: no such file or directory, open '/app/data/modules/package.json' npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN enoent ENOENT: no such file or directory, open '/app/data/modules/package.json' npm WARN modules No description npm WARN modules No repository field. npm WARN modules No README data npm WARN modules No license field. + handlebars@4.7.7 added 6 packages from 39 contributors and audited 6 packages in 0.834s found 0 vulnerabilities āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā npm update check failed ā ā Try running with sudo or get access ā ā to the local update config store via ā ā sudo chown -R $USER:$(id -gn $USER) /root/.config ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā root@XYZ:/app/data/modules# ls -al total 16 drwxr-xr-x 3 root root 4096 Oct 9 16:25 . drwxr-xr-x 8 cloudron cloudron 4096 Oct 9 16:23 .. drwxr-xr-x 9 root root 4096 Oct 9 16:25 node_modules -rw-r--r-- 1 root root 1711 Oct 9 16:25 package-lock.json root@XYZ:/app/data/modules# ls -al node_modules/ total 36 drwxr-xr-x 9 root root 4096 Oct 9 16:25 . drwxr-xr-x 3 root root 4096 Oct 9 16:25 .. drwxr-xr-x 2 root root 4096 Oct 9 16:25 .bin drwxr-xr-x 6 root root 4096 Oct 9 16:25 handlebars drwxr-xr-x 4 root root 4096 Oct 9 16:25 minimist drwxr-xr-x 2 root root 4096 Oct 9 16:25 neo-async drwxr-xr-x 4 root root 4096 Oct 9 16:25 source-map drwxr-xr-x 5 root root 4096 Oct 9 16:25 uglify-js drwxr-xr-x 4 root root 4096 Oct 9 16:25 wordwrap root@XYZ:/app/data/modules# -
@girish I went back to a fresh installation, because I had not checked the changes of the recent updates. This fix allows me to install handelbars. But it still doesn't work, I still get the message
Cannot find module 'handlebars'with this example.My session:
root@XYZ:/app/data# vi env root@XYZ:/app/data# cat env # Set the logging level to 'debug' export EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=true export EXECUTIONS_DATA_SAVE_ON_ERROR=all export EXECUTIONS_DATA_SAVE_ON_SUCCESS=all export N8N_LOG_LEVEL=info export NODE_PATH=/app/data/modules export NODE_FUNCTION_ALLOW_EXTERNAL=handlebars root@XYZ:/app/data# mkdir modules root@XYZ:/app/data# cd /app/data/modules root@XYZ:/app/data/modules# npm install handlebars --cache /tmp/foo npm WARN saveError ENOENT: no such file or directory, open '/app/data/modules/package.json' npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN enoent ENOENT: no such file or directory, open '/app/data/modules/package.json' npm WARN modules No description npm WARN modules No repository field. npm WARN modules No README data npm WARN modules No license field. + handlebars@4.7.7 added 6 packages from 39 contributors and audited 6 packages in 0.834s found 0 vulnerabilities āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā npm update check failed ā ā Try running with sudo or get access ā ā to the local update config store via ā ā sudo chown -R $USER:$(id -gn $USER) /root/.config ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā root@XYZ:/app/data/modules# ls -al total 16 drwxr-xr-x 3 root root 4096 Oct 9 16:25 . drwxr-xr-x 8 cloudron cloudron 4096 Oct 9 16:23 .. drwxr-xr-x 9 root root 4096 Oct 9 16:25 node_modules -rw-r--r-- 1 root root 1711 Oct 9 16:25 package-lock.json root@XYZ:/app/data/modules# ls -al node_modules/ total 36 drwxr-xr-x 9 root root 4096 Oct 9 16:25 . drwxr-xr-x 3 root root 4096 Oct 9 16:25 .. drwxr-xr-x 2 root root 4096 Oct 9 16:25 .bin drwxr-xr-x 6 root root 4096 Oct 9 16:25 handlebars drwxr-xr-x 4 root root 4096 Oct 9 16:25 minimist drwxr-xr-x 2 root root 4096 Oct 9 16:25 neo-async drwxr-xr-x 4 root root 4096 Oct 9 16:25 source-map drwxr-xr-x 5 root root 4096 Oct 9 16:25 uglify-js drwxr-xr-x 4 root root 4096 Oct 9 16:25 wordwrap root@XYZ:/app/data/modules# -
@jeau I have fixed the package to support this. Please try https://docs.cloudron.io/apps/n8n/#custom-node-modules with the latest package 1.16.0
-
@jeau I have fixed the package to support this. Please try https://docs.cloudron.io/apps/n8n/#custom-node-modules with the latest package 1.16.0
-
@girish Two questions:
Do I understand correctly that this is the only way to install external modules ?
Is there anything that need to be done (beside app restart) after adding the line in the env file?
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better š
Register Login
