UNSOLVED 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
but, it doesn't work when I execute my workflow, I have this error
"Cannot find module 'handlebars'"
@jeau I have to check in the package, but looks like we could add the required
handlebarsnode module then in the package directly to get it supported if this is a common thing in n8n
The package already has
N8N_CUSTOM_EXTENSIONS="/app/data/custom"though I don't know if this means that a user can
npm 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
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
So I created a
/app/data/and installed in it the module handlebars with the command
npm 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
@jeau there is a env var
NODE_PATHthat tells node where to find additional node modules. So, you can set the variable in
NODE_PATH=/app/data/modulesand then in Web Terminal:
mkdir /app/data/modules cd /app/data/modules npm install handlebars
Restart the app afterwards.
@girish thanks, however I have this errors after passing the command
npm install handlebars
npm 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.
npm install --prefix /app/data/modules handlebarsbut the result was the same
however, I have already successfully installed handelbars before, but I forgot how to do it
robi last edited by
This post is deleted!
@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.
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. + email@example.com 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#