Cannot get Custom nodes installed because of import from n8n-workflow

Hi,

I’ve got an issue with my custom node deployment in docker.
I put the Nodes and Credentials folder into the custom folder in the docker container. And it does not start anymore. giving the error:

Initializing n8n process,
 ›   Error: There was an error: Cannot find module 'n8n-workflow',
 ›   Require stack:,
 ›   - /home/node/.n8n/custom/nodes/Caspio/GenericFunctions.js,
 ›   - /home/node/.n8n/custom/nodes/Caspio/Caspio.node.js,
 ›   - /usr/local/lib/node_modules/n8n/dist/src/LoadNodesAndCredentials.js,
 ›   - /usr/local/lib/node_modules/n8n/dist/src/index.js,
 ›   - /usr/local/lib/node_modules/n8n/dist/commands/start.js,
 ›   - /usr/local/lib/node_modules/n8n/node_modules/@oclif/config/lib/plugin.js,
 ›   - /usr/local/lib/node_modules/n8n/node_modules/@oclif/config/lib/config.js,
 ›   - /usr/local/lib/node_modules/n8n/node_modules/@oclif/config/lib/index.js,, ›   - ,
 ›   /usr/local/lib/node_modules/n8n/node_modules/@oclif/command/lib/command.js,
 ›   - /usr/local/lib/node_modules/n8n/node_modules/@oclif/command/lib/index.js,
 ›   - /usr/local/lib/node_modules/n8n/bin/n8n,

I’ve read the post thread https://community.n8n.io/t/how-to-add-new-node-in-a-production-setup/7007/32
But it seems like the solution would be to just disable the import, that does not seem like a good solution.
Not sure what the absolute path is of ‘n8n-workflow’
I am importing : import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';

Hope there is an easy way to fix this.
I’ve also created a new node module, but still figuring out why it doesn’t want to build the docker image (using Git actions)

Information on your n8n setup

  • n8n version: latest
  • Database you’re using (default: SQLite): SQLite
  • Running n8n with the execution process [own(default), main]: own
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker

Hey @BramKnuever, I am so sorry to hear you’re having trouble. I too failed at building a custom docker images in the past, so can’t offer any useful advice here unfortunately :sob:

So my personal advice here would be to wait until the community node repo feature is rolled out or to avoid using a custom image right now and go for the documented route based on our standard image instead:

https://docs.n8n.io/integrations/creating-nodes/code/create-n8n-nodes-module/#use-the-n8n-nodes-module-in-production

Hi @MutedJam

As soon as I add the line to add the custom module. It returns an error.
buildx failed with: error: failed to solve: process "/bin/sh -c cd /usr/local/lib/node_modules/n8n && npm install n8n-nodes-caspio" did not complete successfully: exit code: 2
Any idea how to fix this?

when not using the custom but normal dockerfile it gives the error:

build
buildx failed with: error: failed to solve: failed to compute cache key: failed to calculate checksum of ref q1n0028o4yq0tl9keue6w22gp::0z98lp46m0k302gr7fpc583tg: "/docker-entrypoint.sh": not found

trying to build with GitHub actions.
Without this line to add the module it does work as expected.

So I just gave this a go (on my Windows machine even) with a Dockerfile like this:

FROM node:16-alpine

ARG N8N_VERSION

RUN if [ -z "$N8N_VERSION" ] ; then echo "The N8N_VERSION argument is missing!" ; exit 1; fi

# Update everything and install needed dependencies
RUN apk add --update graphicsmagick tzdata git tini su-exec

# # Set a custom user to not have n8n run as root
USER root

# Install n8n and the also temporary all the packages
# it needs to build it correctly.
RUN apk --update add --virtual build-dependencies python3 build-base ca-certificates && \
	npm config set python "$(which python3)" && \
	npm_config_user=root npm install -g full-icu [email protected]${N8N_VERSION} && \
	apk del build-dependencies \
	&& rm -rf /root /tmp/* /var/cache/apk/* && mkdir /root;

# Install n8n-nodes-weather module
RUN cd /usr/local/lib/node_modules/n8n && npm install n8n-nodes-caspio

# Install fonts
RUN apk --no-cache add --virtual fonts msttcorefonts-installer fontconfig && \
	update-ms-fonts && \
	fc-cache -f && \
	apk del fonts && \
	find  /usr/share/fonts/truetype/msttcorefonts/ -type l -exec unlink {} \; \
	&& rm -rf /root /tmp/* /var/cache/apk/* && mkdir /root

ENV NODE_ICU_DATA /usr/local/lib/node_modules/full-icu

WORKDIR /data

COPY docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]

EXPOSE 5678/tcp

I also copied this docker-entrypoint.sh file to the same directory as my Dockerfile and have used docker build --build-arg N8N_VERSION=0.177.0 --tag=n8ntestbram . as my build command. This seems to work fine and I do have access to your node now:

Perhaps you could give this a go? If this works for you as well it might just be that our documentation needs a little update.

1 Like

@MutedJam Thanks! I am working on it. Apparently I also have a very old version of docker which could have been one of the problems.
Ill keep you updated.

1 Like

@MutedJam

It Works, thanks A LOT. :smiley:
The real problem was the docker desktop version, which was way too old. Apparently, time flies and I didn’t notice the version being all messed-up.

1 Like

Awesome, glad to hear this works! Our documentation here also needs an update, so I suppose old docker version + old documentation isn’t a great combination :wink:

We’ll make sure to get that updated soon!

1 Like

@MutedJam , i tried the same thing as Bram, can create the docker build, without any problems,
but if i would like to

docker-compose up

n8n | Initializing n8n process
n8n | › Error: There was an error: Cannot find module ‘/usr/local/lib/node_modules
n8n | › /n8n/node_modules/n8n-nodes-xxxxxx/dist/nodes/SipWise/SipWise.node.js’
n8n | › Require stack:
n8n | › - /usr/local/lib/node_modules/n8n/dist/src/LoadNodesAndCredentials.js
n8n | › - /usr/local/lib/node_modules/n8n/dist/src/index.js
n8n | › - /usr/local/lib/node_modules/n8n/dist/commands/start.js
n8n | › - /usr/local/lib/node_modules/n8n/node_modules/@oclif/config/lib/plugin.js
n8n | › - /usr/local/lib/node_modules/n8n/node_modules/@oclif/config/lib/config.js
n8n | › - /usr/local/lib/node_modules/n8n/node_modules/@oclif/config/lib/index.js
n8n | › -
n8n | › /usr/local/lib/node_modules/n8n/node_modules/@oclif/command/lib/command.js
n8n | › - /usr/local/lib/node_modules/n8n/node_modules/@oclif/command/lib/index.js
n8n | › - /usr/local/lib/node_modules/n8n/bin/n8n

the only thing which it different i install the my modules from git:

RUN cd /usr/local/lib/node_modules/n8n && npm i https://github.com/ilsuky/n8n-nodes-xxxxxx

any idea?

Thanks

Hey @ChristianV,

Have you checked that the files exist in the container, looking at the error that is the first thing I would try.

Did you also take the full custom image approach?

@jon , thanks for your tip, the dist folder is missing between the path:

‘/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-xxxxxx/dist/nodes/SipWise/SipWise.node.js’

its: ‘/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-xxxxxx/nodes/SipWise/SipWise.node.js’

whats here the problem?

1 Like

Hey @ChristianV
If the Dist folder is missing, then this is probably in the .gitignore and simply not on GIT. you do need this though, so changing the gitignore might be the only fix you need.
This is the folder where the build nodes and credentials are stored.

4 Likes

Thanks, that was the problem … .gitignore had the dist folder listened and i forgott to rebuild.

3 Likes