Import dbf-node in code node

selfhosted 1.55.3 npm linux

i need node dbf-node so installed

npm install dbf-node

i have allowed everything in envirnment.

in code node i have

const { Dbf } = require(“dbf-node”);
console.log( Dbf );

but it is empty (also no error in console) … how to get it working?

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:

so get no error and libary is imported

but i get Dbf is not a constructor [line 4, for item 0]

const Dbf = require(“node-dbf”);
const dbf = new Dbf(‘/home/edmunds’);

As an alternative to running n8n directly from npm, or rebuilding a Docker image, if you are running w/ docker-compose, from the directory where docker-compose.yml is…

  1. mkdir extralibs
  2. cd extralibs
  3. npm init
  4. npm i dbf-node
  5. cd ..
  6. edit docker-compose.yml
    add volumes to n8n service for each additional npm lib…
    volumes:
      - ./extralibs/node_modules/dbf-node:/usr/local/lib/node_modules/n8n/node_modules/dbf-node
      - ...etc / other transitive dependencies...
    

Couldn’t say whether this is an appropriate way to do this for a production deployment, but it seems to do the trick just to see if you can get a code node working with the extra libraries.

I think you also still need to have NODE_FUNCTION_ALLOW_EXTERNAL=* in the environment.

It would probably be helpful to get the dbf related code working outside of n8n before trying to get it to work in a code node. Debugging info and error messages will be a lot easier without n8n wrapped around it.

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