~/.npm folder missing - Permissions error updating Nodes

Hi Folks,

Looking for some help on my 'production system'. I have tried to update my Nodes using Manage Palette and I get the errors below. I can't find the home/pi/.npm directory.

I am pretty sure that I updated my nodes after loading NR 3.1.0 and all went OK. I see ~/.npm on my Development system (Ubuntu 22.04, NR 3.1.0), so assume that it should be there.

Is there anyway that I can regenerate this folder without having to do a rebuild. (Rerun the install script?)

I am the only one that works on these systems and I haven't done any delete commands, or at least, I have not intended to carry out any delete/remove commands! :grinning:

2023-11-16T17:11:04.154Z Install : node-red-contrib-cron-plus 2.1.0

2023-11-16T17:11:04.180Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production --engine-strict node-red-contrib-cron-plus@2.1.0
2023-11-16T17:11:05.686Z [err] npm
2023-11-16T17:11:05.687Z [err]  WARN
2023-11-16T17:11:05.687Z [err]  config production Use `--omit=dev` instead.
2023-11-16T17:11:08.292Z [err] npm
2023-11-16T17:11:08.292Z [err]  
2023-11-16T17:11:08.292Z [err] ERR!
2023-11-16T17:11:08.292Z [err]  code EACCES
2023-11-16T17:11:08.293Z [err] npm
2023-11-16T17:11:08.293Z [err]  ERR! syscall mkdir
2023-11-16T17:11:08.293Z [err] npm
2023-11-16T17:11:08.293Z [err]  ERR!
2023-11-16T17:11:08.294Z [err]  
2023-11-16T17:11:08.294Z [err] path /home/pi/.npm
2023-11-16T17:11:08.296Z [err] npm ERR!
2023-11-16T17:11:08.296Z [err]  errno -13
2023-11-16T17:11:08.300Z [err] npm ERR!
2023-11-16T17:11:08.300Z [err]  
2023-11-16T17:11:08.300Z [err] npm ERR! Your cache folder contains root-owned files, due to a bug in
2023-11-16T17:11:08.300Z [err] npm 
2023-11-16T17:11:08.301Z [err] ERR! previous versions of npm which has since been addressed.
2023-11-16T17:11:08.301Z [err] npm ERR!
2023-11-16T17:11:08.301Z [err]  
2023-11-16T17:11:08.301Z [err] npm 
2023-11-16T17:11:08.301Z [err] ERR!
2023-11-16T17:11:08.301Z [err]  To permanently fix this problem, please run:
2023-11-16T17:11:08.301Z [err] npm ERR!   sudo chown -R 1000:1000 "/home/pi/.npm"
2023-11-16T17:11:08.306Z [err] 
2023-11-16T17:11:08.306Z [err] npm
2023-11-16T17:11:08.306Z [err]  ERR! Log files were not written due to an error writing to the directory: /home/pi/.npm/_logs
2023-11-16T17:11:08.306Z [err] npm ERR!
2023-11-16T17:11:08.306Z [err]  You can rerun the command with `--loglevel=verbose` to see the logs in your terminal

Start up Log

Starting as a systemd service.
16 Nov 17:30:28 - [info]
Welcome to Node-RED
16 Nov 17:30:28 - [info] Node-RED version: v3.1.0
16 Nov 17:30:28 - [info] Node.js  version: v18.18.0
16 Nov 17:30:28 - [info] Linux 5.10.103-v7l+ arm LE
16 Nov 17:30:29 - [info] Loading palette nodes
16 Nov 17:30:35 - [info] Dashboard version 3.4.0 started at /ui
16 Nov 17:30:36 - [info] Settings file  : /home/pi/.node-red/settings.js
16 Nov 17:30:36 - [info] Context store  : 'memoryOnly' [module=memory]
16 Nov 17:30:36 - [info] Context store  : 'storeInFile' [module=localfilesystem]
16 Nov 17:30:36 - [info] User directory : /home/pi/.node-red
16 Nov 17:30:36 - [info] Projects directory: /home/pi/.node-red/projects
16 Nov 17:30:36 - [info] Server now running at
16 Nov 17:30:36 - [info] Active project : 2101071_New_Server
16 Nov 17:30:36 - [info] Flows file     : /home/pi/.node-red/projects/2101071_New_Server/flow.json
16 Nov 17:30:36 - [warn] Using unencrypted credentials
16 Nov 17:30:36 - [info] +-----------------------------------------------------
16 Nov 17:30:36 - [info] | uibuilder v6.4.1 initialised
16 Nov 17:30:36 - [info] | root folder: /home/pi/.node-red/projects/2101071_New_Server/uibuilder
16 Nov 17:30:36 - [info] | Using Node-RED's webserver at:
16 Nov 17:30:36 - [info] |
16 Nov 17:30:36 - [info] | Installed packages:
16 Nov 17:30:36 - [info] +-----------------------------------------------------
16 Nov 17:30:37 - [info] Starting flows

Home Directory

ls -la
total 150072
drwxr-xr-x 15 root root     4096 Oct  4 18:32 .
drwxr-xr-x  3 root root     4096 Dec  2  2020 ..
-rw-------  1 pi   pi      34966 Nov 16 17:09 .bash_history
-rw-r--r--  1 pi   pi        220 Dec  2  2020 .bash_logout
-rw-r--r--  1 pi   pi       3523 Dec  2  2020 .bashrc
drwxr-xr-x  4 pi   pi       4096 Mar  2  2023 .cache
drwx------  5 pi   pi       4096 Jan  7  2021 .config
drwx------  3 pi   pi       4096 Feb  2  2023 .gnupg
drwx------  5 pi   pi       4096 Jan  9  2021 InfluxDB
drwxr-xr-x  5 pi   pi       4096 Oct 11  2021 influxdb-1.8.10-1
drwxr-xr-x  2 pi   pi      28672 Nov 16 03:36 InfluxDB-storage
-rw-r--r--  1 pi   pi       3140 Mar 12  2023 .influx_history
drwxr-xr-x  3 pi   pi       4096 Jan  7  2021 .local
drwxr-xr-x  7 pi   pi       4096 Nov 16 17:30 .node-red
drwxr-xr-x  2 pi   pi       4096 Nov 16 03:23 node-red-storage
-rw-------  1 pi   pi         22 Oct  4 18:33 .npmrc
drwxr-xr-x  2 pi   pi       4096 Dec 23  2022 NRconfigFiles
-rw-r--r--  1 pi   pi        807 Dec  2  2020 .profile
drwx------  3 pi   pi       4096 May 17  2021 sftp:
drwx------  2 pi   pi       4096 Aug  2  2022 .ssh
drwxr-xr-x  5 root root     4096 Feb 27  2023 telegraf-1.25.3
-rw-r--r--  1 pi   pi     452570 Apr 18  2023 telegraf.conf

Any help gratefully received.

Did you try to follow this advice?

1 Like

I suspect that is actually the problem. Your home folder should be owned by you (pi) I think this might be a good command to use
sudo chown -R pi:pi /home/pi
and see if that fixes it in the ls command.

Editted above command as I had said chmod instead of chown


Thank you guys for the help. Much appreciated!
Here are the results of the two commands via ssh to an RPi4 on Raspberry OS (Sorry, forgat that information yesterday.)


sudo chmod -R pi:pi /home/pi
chown: cannot access '/home/pi/.npm': No such file or directory


sudo chmod -R pi:pi /home/pi
chmod: invalid mode: ‘pi:pi’
Try 'chmod --help' for more information.

The .npm folder is not there, so I can understand the chown failing. I did try the suggested command from the reported error and that is how I found that .npm was missing. I have no idea why chmod fails.

I ran chown on the pi folder and all permissions are now pi:pi, but still no .npm .

The .npm directory is created by npm when it installs new modules. If it’s not there and now the overall directory is owned by pi:pi you should be able to run an npm command (from within the .node-red directory ) and it should now get recreated

1 Like

Thank you Dave.

I was not sure about running this command as I don't understand if it can do damage!
.npm now present and updates in Manage Palette now working!

Sorry, as you have worked out, that should have been chown not chmod.
I have corrected my post above in case others find it.

1 Like

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