userDir configuration

Hello, I'm a newbie to node-red and am unable to figure out the proper configuration value for userDir.

I looked at the User Guide but still, where am I supposed to create the directory for the user nol?

I see a new folder was created at the root of my project $HOME with the directory .nodered in it.

Should my userDir value be /home/.nodered/ or should I create a new directory myUser in $HOME and the userDir value be /home/myUser/.nodered/?

Thank you

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { json } from 'express';

async function bootstrap() {
	const app = await NestFactory.create(AppModule);
	app.enableCors();
	app.use(json({ limit: '50mb' }));

	const config = new DocumentBuilder()
		.setTitle('OAST')
		.setDescription('The OAST API description')
		.setVersion('0.1')
		.build();

	const document = SwaggerModule.createDocument(app, config);
	SwaggerModule.setup('api', app, document);

	/**
	 * Configure node-red
	 */
	const httpAdapter = app.getHttpAdapter();
	const RED = require('node-red');

	// Settings object for node-red
	const nodeRedSettings = {
		httpAdminRoot: '/red',
		httpNodeRoot: '/api',
		userDir: '/home/nol/.nodered/',
		functionGlobalContext: {}, // enables global context
	};

	RED.init(httpAdapter, nodeRedSettings);
	// Serve the editor UI from /red
	app.use(nodeRedSettings.httpAdminRoot, RED.httpAdmin);
	// Serve the http nodes UI from /api
	app.use(nodeRedSettings.httpNodeRoot, RED.httpNode);

	await app.listen(3001);

	// Start the runtime
	RED.start();
}
bootstrap();

Hi @ax2382.

I guess you are using Linux?
What variety of Linux?
If it's Debian based use the Raspberry Pi installation script and it will automatically do everything you need. No need to create directories.
Ps. Unless you are using Docker or something like that

Do you actually have a user "nol"? I know that's used as an example in some places but you don't need to use it.
For example, on my raspberry pi I installed Node-red as the user "pi". The NR base directory is /home/pi/.node-red

'nol' stands for Nick O'Leary one of the developers of Node-RED. So you would use the user id you are installing Node-RED with.

As @jbudd said, if you are doing this on a raspberry, the current install script will generate the settings.js file. If you are using the current script, you will see this:

/** By default, all user data is stored in a directory called `.node-red` under
     * the user's home directory. To use a different location, the following
     * property can be used
     */
    //userDir: '/home/nol/.node-red/',

as you can see, that option is commented out as a default.

That option is useful if you want to change the default location of your user data.

@jbudd @zenofmud interesting responses... I'm installing in a Nest.js web app which is an MVC wrapper of Express.js web app, which is a library of Node.js so, in essence, I'm installing it in a Node.js web app in a Windows environment... I did not have to provide a user when installing...

Thank you!

It just needs to be an absolute path to the directory you want to store Node-RED data in. It can be absolutely anywhere you want.

I don't know what any of that means but it definitely suggests that my response above has no relevance to your question.

@knolleary Ok. Taking the default path value as a reference... and being that node-red created a new folder named $HOME in my project root: is /home/ pointing to $HOME?

Currently, node-red installed itself under $HOME... therefore I assume my value should be:
userDir: '/home/.nodered/'

:sweat_smile: thank you anyways!

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