Seting up a local builld / dev environment

reading this help forum I found others talking about the build environment but so far cannot find a solution to my particular problem. My apologies if this is a repeat.

I am new to n8n so wanted to run up an environment locally for myself which I am able to in non-dev mode with npm install n8n and will go on to run a docker containder so that is all good. However I would love to be able to extend n8n for anything I find usefull and ideally be able to give this back. I’m ok with Javascript but new to Typescript so please forgive my ignorance in this regard.

My problem is so far getting an npm build to run witout error. I think I’ve resolved dependency issues in my environment but am getting what I believe to be a typescript error.

So starting with a clean fork / clone locally of the current main branch as of the time of this posting I found that in order to get npm install && npm build to work thus far I needed to install a bunch of pre-requisites that I believe are for the most part typescript related ( please forgive my ignorance of typescript as I am pretty new to it being a longer term user of plain javascript ) - but I think I’ve got all of the deps installed :

@oclif/command react-scripts bootstrap @types/luxon @types/xml2js && npm @types/lodash @types/lodash.merge @types/lodash.get @types/lodash.set @types/jest @types/jmespath @types/uuid

so I think I’ve got the needed environment however I still get the following build error:

n8n-workflow:build: > [email protected] build /home/user/projects/n8n/packages/workflow
n8n-workflow:build: > tsc
n8n-workflow:build: src/RoutingNode.ts(244,6): error TS2769: No overload matches this call.
n8n-workflow:build:   Overload 1 of 4, '(target: {}, source: IN8nRequestOperations): IN8nRequestOperations', gave the following error.
n8n-workflow:build:     Argument of type 'IN8nRequestOperations | undefined' is not assignable to parameter of type '{}'.
n8n-workflow:build:       Type 'undefined' is not assignable to type '{}'.
n8n-workflow:build:   Overload 2 of 4, '(target: object, ...sources: any[]): any', gave the following error.
n8n-workflow:build:     Argument of type 'IN8nRequestOperations | undefined' is not assignable to parameter of type 'object'.
n8n-workflow:build:       Type 'undefined' is not assignable to type 'object'.
n8n-workflow:build: npm ERR! code ELIFECYCLE
n8n-workflow:build: npm ERR! errno 2
n8n-workflow:build: npm ERR! [email protected] build: `tsc`
n8n-workflow:build: npm ERR! Exit status 2
n8n-workflow:build: npm ERR! 
n8n-workflow:build: npm ERR! Failed at the [email protected] build script.

I’m running on ubuntu jammy and node v14.20.0

is this a known issue just and if so, would I be best checking out an earlier version ?

any help greatly appreciated

Hi @marshyon,
welcome to the community :tada:

To develop n8n you have to install nodejs.

Our github repo n8n-io/n8n is a multi package solution and we use lerna as a build system. First thing you need to do is to install lerna globally.

npm install lerna -g

Then in the root folder of your n8n fork you use lerna to install all npm packages, this will also setup all package depencies inside our github repo.

lerna bootstrap --hoist

After that you should be able to

npm run build
npm run dev

Can you try this out with a fresh github repo checkout.

Hi Marcus,

thanks for your rapid reply. I’m new to lerna so thanks for letting me know.

I’m running the recommended node version of 14, v14.20.0 to be precise and have installed lerna globally. In a fresh clone of n8n:

$ cd n8n/
$ lerna bootstrap --hoist
lerna notice cli v5.3.0
lerna ERR! ENOLERNA `lerna.json` does not exist, have you run `lerna init`?

so I did a lerna init

$ lerna init
lerna notice cli v5.3.0
lerna info Updating package.json
lerna info Creating lerna.json
lerna info Creating packages directory
lerna success Initialized Lerna files
lerna info New to Lerna? Check out the docs:

was I right in doing this ?

then I could run

$ lerna bootstrap --hoist
added 968 packages from 371 contributors and audited 982 packages in 126.019s

57 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

however many further dependencies are needed for example

npm install typescript gulp gulp-dart-sass gulp-autoprefixer gulp-clean-css

and this is just a short list, so I think I’m still missing something with the lerna command ?

Hey @marshyon,
I just received notice that we changed our build system from lerna to turbo over the weekend :upside_down_face: so the lerna approach won’t work anymore, sorry.

From here on out you should use nodejs version >=16. Please make a fresh github repo checkout or delete all of your node_modules folders (nested too).

To install npm dependencies simply run

npm install

To build and start n8n

npm run build
npm run start

While developing you can use one of these

# will recompile and run n8n
npm run dev

# use 2 seperate terminals to
npm run watch
npm run start

Hi Marcus,

I’ve done as you said, re-cloned, switched to node v16.16.0 ( thanks to nvm install 16 ), the npm run build, npm run start runs without any of the previous errors I got.

thanks very much for your help.

May I also say whilst we’re talking on things n8n, I think ‘no-code’ is a very big thing to be taken very seriously, n8n being open source and available to be run locally to develop new features and even host on-prem puts n8n light years ahead of other no-code solutions similar.

I found out about n8n on youtube c/o awsome open source and glad I did. Only complaint is I didnt find n8n sooner. I help run a charity in the UK and was looking for something like this. Couldnt be happier.

thanks again

1 Like

Hi marshyon,
thanks for the kind words. Yeah I also saw the youtube video by awesome open source. I subscribed to his channel long time ago, He is awesome and we are very happy that he showcased n8n.