# ~/.npm folder missing - Permissions error updating Nodes

**URL:** <https://discourse.nodered.org/t/npm-folder-missing-permissions-error-updating-nodes/82938>\
**Category:** General\
**Created:** [16 November 2023 18:04 UTC](https://discourse.nodered.org/t/npm-folder-missing-permissions-error-updating-nodes/82938 "2023-11-16T18:04:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mudwalker](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mudwalker](https://discourse.nodered.org/u/mudwalker)\
**Post date:** [16 November 2023 18:04 UTC](https://discourse.nodered.org/t/npm-folder-missing-permissions-error-updating-nodes/82938/1 "2023-11-16T18:04:50Z")

</div>

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! 😀

```auto
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

```auto
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 http://127.0.0.1:1880/
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] | http://0.0.0.0:1880/
16 Nov 17:30:36 - [info] | Installed packages:
16 Nov 17:30:36 - [info] +-----------------------------------------------------
16 Nov 17:30:37 - [info] Starting flows

```

Home Directory

```auto
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.  
TIA

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [16 November 2023 19:51 UTC](https://discourse.nodered.org/t/npm-folder-missing-permissions-error-updating-nodes/82938/2 "2023-11-16T19:51:25Z")

</div>

> [@mudwalker](#):
>
> ```auto
> 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"
> 
> ```

Did you try to follow this advice?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 November 2023 20:53 UTC](https://discourse.nodered.org/t/npm-folder-missing-permissions-error-updating-nodes/82938/3 "2023-11-16T20:53:02Z")

</div>

> [@mudwalker](#):
>
> ```auto
> drwxr-xr-x 15 root root 4096 Oct 4 18:32 .
> drwxr-xr-x 3 root root 4096 Dec 2 2020 ..
> 
> ```

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

---

<div class="post-metadata">

**Author:** ![mudwalker](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mudwalker](https://discourse.nodered.org/u/mudwalker)\
**Post date:** [17 November 2023 09:42 UTC](https://discourse.nodered.org/t/npm-folder-missing-permissions-error-updating-nodes/82938/4 "2023-11-17T09:42:49Z")

</div>

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.)

@ralphwetzel

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

```

@Colin

```auto
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` .

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [17 November 2023 09:50 UTC](https://discourse.nodered.org/t/npm-folder-missing-permissions-error-updating-nodes/82938/5 "2023-11-17T09:50:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mudwalker](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mudwalker](https://discourse.nodered.org/u/mudwalker)\
**Post date:** [17 November 2023 09:55 UTC](https://discourse.nodered.org/t/npm-folder-missing-permissions-error-updating-nodes/82938/6 "2023-11-17T09:55:32Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 November 2023 10:01 UTC](https://discourse.nodered.org/t/npm-folder-missing-permissions-error-updating-nodes/82938/7 "2023-11-17T10:01:30Z")

</div>

> [@mudwalker](#):
>
> @Colin
> 
> ```auto
> sudo chmod -R pi:pi /home/pi
> chmod: invalid mode: ‘pi:pi’
> 
> ```

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [1 December 2023 10:01 UTC](https://discourse.nodered.org/t/npm-folder-missing-permissions-error-updating-nodes/82938/8 "2023-12-01T10:01:31Z")

</div>

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