Settings.js "Error writing settings.js:Permission denied"

Trying to set the a Username and Password for Node Red.

The instructions require that in "settings.js" be modfied.

I have edited the field and removed the comment //.
Then tried to save by pressing ctrl+o ( ^o)
However i get Error " Error writing settings.js: Permission denied"

Any suggestions?

adminAuth:{
type: "credentials",
.....
.....
},

figured it out. need to enter sudo nano settings.js ( forgot to type in the sudo)

Which settings.is are you editing? If you look at the node red log it will tell you which one it is using. Normally this will be .node-red/settings.js and should not need sudo to edit.

1 Like

Thank you Collin.
During bootup, the PI shows that following path name:
"usr/lib/node_modules/node-red/settings.js"

the Node Red was installed from the NOOB installation

  1. I am pretty confused on where the settings.js file should be.
    Is the settings.js supposed to be located elsewhere?

You should run the bash <(curl upgrade script from the pi installation docs [1]. Then your flows file and settings.js should be in ~/.node-red. The pre-installed node-red is out of date.

[1] https://nodered.org/docs/hardware/raspberrypi

Normally on first run the settings.js file gets copied to ~/.node-red/ directory and is used from there. There are a few reasons why this may not happen (which I can’t recall). You could move it manually I think.

Thank you Colin.
Ran the bash < curl( ) as you suggested. The directories are all in the /pi/home now.
THank you

Hi all...
Want to setup some user/pass and always get settings.js as read only.
My settings.js seems to be the one at: /snap/node-red/388/lib/node_modules/node-red, there are others but this in the only one that shown contents that include the adminAuth: {... and all the rest.
It is always read only owned by root.
Sudo cannot changed it. sudo -i turns me into root but I still find the file read only.
Tried changing current dir to the path above and execute: sudo chmod 766 -R settings.js
But still cannot edit settings.js, read only

What am I doing wrong?
Regards
Paulo

Hi Paulo, how do you run node-red normally? From a service, calling sudo node-red or something else entirely?

That should indeed be read-only and should not be the live version you are running with. That one would appear to be the master one provided in the Node-RED package.

You should have another one in your userDir folder so that is what you need to focus on. If you don't have it there, you can manually copy it from the other location.

That you cannot edit it is a benefit and one I suspect that snap is enforcing somehow.

2 Likes

Hi, I see...
Excuse my ignorance but when I open terminal and type ls what I see is:
pcborges@ubuntu:~$ ls
'Area de Trabalho' Downloads influxdbinstall Music snap
Documents Images Models Public Videos

I see no node-red
Should I create a node-red folder?
Where do I copy settings.js to?
Thanks
Paulo

Hi afelix,
I do nothing, installed, reboot and it is running.
Thanks
Paulo

The node-red folder starts with a ., that means it's hidden from the view by default. If you pass the -a option it will show everything including hidden files/folders. If you add -l it will show it as list:
ls -a -l

afelix@Hewlett:~$ ls -a -l
total 1464
drwxr-xr-x+  108 afelix  staff    3456 Sep  1 11:55 .
drwxr-xr-x     6 root    admin     192 Mar 28 16:06 ..
-rw-r--r--@    1 afelix  staff   69636 Sep  4 08:23 .DS_Store
drwx------     2 afelix  staff      64 Aug 28 16:31 .Trash
-rw-------     1 afelix  staff       0 Sep 26  2016 .Xauthority
drwxr-xr-x     6 afelix  staff     192 Dec 29  2018 .heroku
-rw-------     1 afelix  staff     213 Dec 28  2018 .netrc
drwxr-xr-x     4 afelix  staff     128 May 18  2017 .node-gyp
drwxr-xr-x    16 afelix  staff     512 Aug 23 14:28 .node-red
drwxr-xr-x  2440 afelix  staff   78080 Aug 21 20:40 .npm
1 Like

Great, it is indeed there. Thanks
cd .node-red worked but the directory is empty
So, I assume I copy settings.js to /snap/node-red/388/lib/node_modules/node-red and edit it accordingly right?
Thanks again

Clearly, your installation went wrong because Node-RED would populate the .node-red folder upon first run. It will copy over settings.js, create your initial flows files and a package.json.

1 Like

Something is still wrong...
I copied the settings.js from the folder /snap/node-red/388/lib/node_modules/node-red into the folder .node-red (under home) and uncommented:

adminAuth: {
    type: "credentials",
    users: [  {
            username: "admin",
            password: "$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN.",
            permissions: "*"
        }  ]
}

Reboot
Browsed from another computer into: http://192.168.99.105:1880/
But node-red asks for no password, goes straight into the editor.

Should I uninstall and reinstall node-red?
I did an automatic install using ubuntu GUI, is it ok?

Back to my earlier question, how do you start node-red?

When it starts it shows you a log of what settings file it is using, node-red version, node version and so on. Are you sure the settings.js file in ~/.node-red is being used?

As I said, I just installed using Ubuntu GUI and that is all I did
When I reboot the HiperV machine node-red is already running.

pcborges@ubuntu:~/.node-red$ ls
settings.js

I'm not sure if you said "Ubuntu GUI" specifically but I'm going to assume you said so and just move on. Does Ubuntu use SystemD these days or something else? Can you try the following two commands and post the output, I don't know which of those you need:
sudo systemctl status node-red
sudo service node-red status

GUI, I am referring to the the graphic user interface, not the command prompt.

The first returns:
sudo: system: command not found

The second returns:
Unit node-red.service could not be found

I am transcribing because the browser is not in the virtual machine running ubuntu...

Looks like something definitely went wrong during the install but except for this authentication problem node red is working and integrating with grafana without any other problem.


Hi, cannot post more than 3 repplies...

I assume deinstall using the Ubuntu user interface.
Will do and report back
Thanks

###############################################################
Hi there...
Still cannot post new replies...
But just did uninstall using the GUI and reinstalled according to the link
Works perfect, even took the settings.js I have created with the password I defined.
Thanks a lot!
Paulo