I am trying to build the ‘n8n-nodes-starter’ project according to the tutorial on youtube.
The problem is that the build fails when using docker image 0.193.0 or later with the following error:
[4/4] RUN cd /n8n-nodes-starter && npm i && npm run build && npm pack && cd /usr/local/lib/node_modules/n8n && npm install /n8n-nodes-starter/n8n-nodes-my-first-node-0.1.0.tgz:
#8 3.154
#8 3.154 up to date in 2s
#8 3.745
#8 3.745 > [email protected] build
#8 3.745 > tsc && gulp build:icons
#8 3.745
#8 3.751 sh: tsc: not found
In the tutorial 0.190.0 is used and it works as well as 0.192.0.
Is something changed in the images or is it a bug?
ARG N8N_VESRION
FROM n8nio/n8n:$N8N_VESRION
RUN mkdir /n8n-nodes-starter
COPY . /n8n-nodes-starter
RUN cd /n8n-nodes-starter && npm i && npm run build && npm pack \
&& cd /usr/local/lib/node_modules/n8n && npm install /n8n-nodes-starter/n8n-nodes-my-first-node-0.1.0.tgz
It is the same as in the tutorial, except for the name of the node.
Please be aware that without changing anything in Dockerfile or anywhere in the node code on the previous version of the docker image it just works.
I have just updated one of my community nodes with an example Dockerfile which works.
The the should be generic enough to just work with any community node if you wanted to build an image that way and not publish it to npm.
The Dockerfile itself looks like this…
ARG N8N_VERSION
FROM n8nio/n8n:$N8N_VERSION
RUN npm config set -g production false
RUN mkdir /working-dir
COPY . /working-dir
RUN cd /working-dir && npm install && npm run build && npm pack && \
cd /usr/local/lib/node_modules/n8n && npm install /working-dir/*.tgz
RUN rm -rf /working-dir
RUN npm config set -g production true
Thank you, @Jon. Your Dockerfile solved the problem. RUN npm config set -g production false command was missing in my file which caused build was failing.
I had to do some digging to find that one, It turns out if node is in production mode it won’t install the dev dependencies and it causes the failures.