Can't install from the palette in node-red server running on Windows 10

I've used node-red on an RPi for several years. I'm doing a presentation on node-red next week so I installed a local copy on my laptop (Windows 10 x64, MS surface) using the instructions at Running on Windows : Node-RED.

I had an old version of nodejs on my system so I upgraded to the latest LTS. I had it install all the build tools as well. I had no errors installing node.

node --version
v18.13.0

npm --version
9.4.0

I then installed node-red via the NPM package manger without any errors.
npm install -g --unsafe-perm node-red

node-red runs just fine. However, I can't install from the palette. When I attempt to do so, it seems NPM is trying to create the directory C:\

29 Jan 20:39:29 - [info] Server now running at http://127.0.0.1:1880/
29 Jan 20:39:29 - [info] Starting flows
29 Jan 20:39:29 - [info] Started flows
29 Jan 20:40:05 - [info] Installing module: node-red-dashboard, version: 3.3.1
29 Jan 20:40:07 - [warn] Installation of module node-red-dashboard failed:
29 Jan 20:40:07 - [warn] ------------------------------------------
29 Jan 20:40:07 - [warn] npm WARN config production Use `--omit=dev` instead.
npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path c:\
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'c:\'
npm ERR!  [Error: EPERM: operation not permitted, mkdir 'c:\'] {
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: 'c:\\'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\James\AppData\Local\npm-cache\_logs\2023-01-30T03_40_07_182Z-debug-0.log

29 Jan 20:40:07 - [warn] ------------------------------------------
Error: Install failed
    at C:\Users\James\AppData\Roaming\npm\node_modules\node-red\node_modules\@node-red\registry\lib\installer.js:285:25
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
29 Jan 20:40:07 - [error] Error: Install failed
29 Jan 20:41:11 - [info] Stopping flows
29 Jan 20:41:11 - [info] Stopped flows

If I use the manual install process via NPM it works just fine.

c:\Users\James\.node-red% npm install node-red-dashboard

added 54 packages, and audited 55 packages in 2s

found 0 vulnerabilities

And restarting, node-red shows that dashboard is now installed as expected.

I have this same issue regardless of which module I attempt to install.

I figured maybe something odd was going on with the install so I uninstalled node, killed the .node-red folder under my user account, reinstalled node & node-red. But, sadly, same results.

Anyone have any ideas why node-red on windows isn't able to do an npm install node-red-dashboard correctly? Seems like it's some node-red config issue since I can do a straight npm install without a problem.

Any thoughts / help would be appreciated.

Could you show the start of the log please.

This is normal. You have to have admin permissions normally to install anything at the root of C:, this is a sensible security precaution by Microsoft. It would mean that you always had to start Node-RED with elevated privileges and this is a really dangerous thing to do and almost certainly not what you actually want.

It shows that there is something odd about your installation because normally, a "standard" install of Node-RED would give you a userDir folder at ~/.node-red/ and you wouldn't have the problem.

I suspect that you are starting Node-RED from the Windows task scheduler and making it start before user login? If so, you will need to do something extra to ensure that Node-RED has the correct paths set up and probably will have to set a userDir manually.

I just open an administrator terminal and boot up the node-red server for a moment to install a package, then stop the server and restart it as the regular user.

Nothing interesting, but here you go ...

c:\Users\James\.node-red% node-red
29 Jan 20:39:27 - [info]

Welcome to Node-RED
===================

29 Jan 20:39:27 - [info] Node-RED version: v3.0.2
29 Jan 20:39:27 - [info] Node.js  version: v18.13.0
29 Jan 20:39:27 - [info] Windows_NT 10.0.19045 x64 LE
29 Jan 20:39:28 - [info] Loading palette nodes
29 Jan 20:39:29 - [info] Settings file  : C:\Users\James\.node-red\settings.js
29 Jan 20:39:29 - [info] Context store  : 'default' [module=memory]
29 Jan 20:39:29 - [info] User directory : \Users\James\.node-red
29 Jan 20:39:29 - [warn] Projects disabled : editorTheme.projects.enabled=false
29 Jan 20:39:29 - [info] Flows file     : \Users\James\.node-red\flows.json
29 Jan 20:39:29 - [info] Creating new flow file
29 Jan 20:39:29 - [warn] Encrypted credentials not found
29 Jan 20:39:29 - [info] Server now running at http://127.0.0.1:1880/

And here's the actual log file it generated ...

0 verbose cli C:\Program Files\nodejs\node.exe c:\Users\James\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
1 info using npm@9.4.0
2 info using node@v18.13.0
3 timing npm:load:whichnode Completed in 2ms
4 timing config:load:defaults Completed in 2ms
5 timing config:load:file:c:\Users\James\AppData\Roaming\npm\node_modules\npm\npmrc Completed in 1ms
6 timing config:load:builtin Completed in 1ms
7 warn config production Use `--omit=dev` instead.
8 timing config:load:cli Completed in 2ms
9 timing config:load:env Completed in 0ms
10 timing config:load:file:c:\.npmrc Completed in 0ms
11 timing config:load:project Completed in 2ms
12 timing config:load:file:C:\Users\James\.npmrc Completed in 1ms
13 timing config:load:user Completed in 1ms
14 timing config:load:file:c:\Users\James\AppData\Roaming\npm\etc\npmrc Completed in 0ms
15 timing config:load:global Completed in 0ms
16 timing config:load:setEnvs Completed in 1ms
17 timing config:load Completed in 11ms
18 timing npm:load:configload Completed in 11ms
19 timing npm:load:mkdirpcache Completed in 1ms
20 timing npm:load:mkdirplogs Completed in 0ms
21 verbose title npm install node-red-dashboard@3.3.1
22 verbose argv "install" "--no-audit" "--no-update-notifier" "--no-fund" "--save" "--save-prefix" "~" "--production" "--engine-strict" "node-red-dashboard@3.3.1"
23 timing npm:load:setTitle Completed in 3ms
24 timing config:load:flatten Completed in 4ms
25 timing npm:load:display Completed in 5ms
26 verbose logfile logs-max:10 dir:C:\Users\James\AppData\Local\npm-cache\_logs\2023-01-30T03_40_07_182Z-
27 verbose logfile C:\Users\James\AppData\Local\npm-cache\_logs\2023-01-30T03_40_07_182Z-debug-0.log
28 timing npm:load:logFile Completed in 7ms
29 timing npm:load:timers Completed in 0ms
30 timing npm:load:configScope Completed in 0ms
31 timing npm:load Completed in 31ms
32 timing arborist:ctor Completed in 2ms
33 silly logfile start cleaning logs, removing 6 files
34 timing command:install Completed in 8ms
35 verbose stack Error: EPERM: operation not permitted, mkdir 'c:\'
36 verbose cwd c:\
37 verbose Windows_NT 10.0.19045
38 verbose node v18.13.0
39 verbose npm  v9.4.0
40 error code EPERM
41 error syscall mkdir
42 error path c:\
43 error errno -4048
44 error [Error: EPERM: operation not permitted, mkdir 'c:\'] {
44 error   errno: -4048,
44 error   code: 'EPERM',
44 error   syscall: 'mkdir',
44 error   path: 'c:\\'
44 error }
45 error
45 error The operation was rejected by your operating system.
45 error It's possible that the file was already in use (by a text editor or antivirus),
45 error or that you lack permissions to access it.
45 error
45 error If you believe this might be a permissions issue, please double-check the
45 error permissions of the file and its containing directories, or try running
45 error the command again as root/Administrator.
46 verbose exit -4048
47 timing npm Completed in 68ms
48 verbose unfinished npm timer reify 1675050007241
49 verbose code -4048
50 error A complete log of this run can be found in:
50 error     C:\Users\James\AppData\Local\npm-cache\_logs\2023-01-30T03_40_07_182Z-debug-0.log

In fact, I have a .node-red folder under my user account. C:\Users\James\.node-red. That's the folder I start node-red from. It's also the folder I'm in when I do npm install <module>.

I'm starting node-red from the command line, not auto starting from the system, task scheduler, etc.

c:\Users\James\.node-red% node-red
29 Jan 20:39:27 - [info]

Welcome to Node-RED
===================

29 Jan 20:39:27 - [info] Node-RED version: v3.0.2
29 Jan 20:39:27 - [info] Node.js  version: v18.13.0
29 Jan 20:39:27 - [info] Windows_NT 10.0.19045 x64 LE
29 Jan 20:39:28 - [info] Loading palette nodes
29 Jan 20:39:29 - [info] Settings file  : C:\Users\James\.node-red\settings.js
29 Jan 20:39:29 - [info] Context store  : 'default' [module=memory]
29 Jan 20:39:29 - [info] User directory : \Users\James\.node-red
29 Jan 20:39:29 - [warn] Projects disabled : editorTheme.projects.enabled=false
29 Jan 20:39:29 - [info] Flows file     : \Users\James\.node-red\flows.json
29 Jan 20:39:29 - [info] Creating new flow file
29 Jan 20:39:29 - [warn] Encrypted credentials not found
29 Jan 20:39:29 - [info] Server now running at http://127.0.0.1:1880/

For you and @HaroldPetersInskipp -
I am running in an elevated (Administrator) command prompt. However, if I do the same thing from a "standard" command prompt (not administrator) I get the same results.

So the installer is trying to create a new folder at c:\ which is obviously wrong and is being blocked by the OS - way-to-go Microsoft because that is absolutely correct.

The real question is what is causing that. Sadly, the npm log doesn't contain enough information to work that out unless I've missed something.

I have a couple of suspicions but nothing solid.

So firstly try this:

cd c:\Users\James\.node-red
npm install aaa

aaa is a kind of dummy node.js module that is useful for testing npm. If it works, you can remove it again. Let us know whether that works or not.

My main suspicion is that your elevated command prompt has messed things up. If that is the case, probably safest to at least stop node-red, rename the .node-red folder and uninstall node-red. Then exit the elevated prompt and reinstall node-red and do an initial start to recreate the .node-red folder. Then see if the palette manager works.

NOTE: I have tried moving back to node 14.17.6 to see if that made any difference. These results are using node v14 rather than v18.

Manual installs via npm from the command line work just fine. It's only attempts via the palette manager that fail.

c:\Users\James\.node-red% npm install aaa
+ aaa@0.0.2
added 1 package from 1 contributor and audited 55 packages in 4.176s
found 0 vulnerabilities


c:\Users\James\.node-red% npm uninstall aaa
removed 1 package and audited 54 packages in 0.632s
found 0 vulnerabilities

You are thinking along the same track that I am. Why does NPM (via palette manager) think it should be in the root rather than in c:\users\james\.node-red?

Per your suggestion, I uninstalled (via elevated prompt) node-red with npm uninstall -g node-red.

Then I started a non-elevated prompt and reinstalled node-red which worked fine (no errors, etc.)

c:\Users\James% npm install -g --unsafe-perm node-red
C:\Users\James\AppData\Roaming\npm\node-red -> C:\Users\James\AppData\Roaming\npm\node_modules\node-red\red.js
C:\Users\James\AppData\Roaming\npm\node-red-pi -> C:\Users\James\AppData\Roaming\npm\node_modules\node-red\bin\node-red-pi

> bcrypt@5.0.1 install C:\Users\James\AppData\Roaming\npm\node_modules\node-red\node_modules\bcrypt
> node-pre-gyp install --fallback-to-build

[bcrypt] Success: "C:\Users\James\AppData\Roaming\npm\node_modules\node-red\node_modules\bcrypt\lib\binding\napi-v3\bcrypt_lib.node" is installed via remote
+ node-red@3.0.2
added 289 packages from 373 contributors in 20.816s

Then I started node-red from that same non-elevated prompt and attempted to install the dashboard node. No joy. Note that node-red lists the correct user directory at startup.

c:\Users\James% node-red
30 Jan 17:11:04 - [info]

Welcome to Node-RED
===================

30 Jan 17:11:04 - [info] Node-RED version: v3.0.2
30 Jan 17:11:04 - [info] Node.js  version: v14.17.6
30 Jan 17:11:04 - [info] Windows_NT 10.0.19045 x64 LE
30 Jan 17:11:05 - [info] Loading palette nodes
30 Jan 17:11:06 - [info] Settings file  : C:\Users\James\.node-red\settings.js
30 Jan 17:11:06 - [info] Context store  : 'default' [module=memory]
30 Jan 17:11:06 - [info] User directory : C:\Users\James\.node-red
30 Jan 17:11:06 - [warn] Projects disabled : editorTheme.projects.enabled=false
30 Jan 17:11:06 - [info] Flows file     : C:\Users\James\.node-red\flows.json
30 Jan 17:11:06 - [info] Creating new flow file
30 Jan 17:11:06 - [warn]

---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

30 Jan 17:11:06 - [info] Server now running at http://127.0.0.1:1880/
30 Jan 17:11:06 - [warn] Encrypted credentials not found
30 Jan 17:11:06 - [info] Starting flows
30 Jan 17:11:06 - [info] Started flows
30 Jan 17:11:39 - [info] Installing module: node-red-dashboard, version: 3.3.1
30 Jan 17:11:42 - [info] Installed module: node-red-dashboard
30 Jan 17:11:42 - [warn] Installation of module node-red-dashboard failed:
30 Jan 17:11:42 - [warn] ------------------------------------------
30 Jan 17:11:42 - [warn] undefined
30 Jan 17:11:42 - [warn] ------------------------------------------
Error: Install failed
    at C:\Users\James\AppData\Roaming\npm\node_modules\node-red\node_modules\@node-red\registry\lib\installer.js:285:25
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
30 Jan 17:11:42 - [error] Error: Install failed

And here's a copy of the npm log. Note the C:\package.json indicating it's looking in the root, not in .node-red under my home dir.

2023-01-31T00:11:38.756Z Install : node-red-dashboard 3.3.1

2023-01-31T00:11:39.076Z npm.cmd install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production --engine-strict node-red-dashboard@3.3.1
2023-01-31T00:11:42.115Z [err] npm
2023-01-31T00:11:42.115Z [err]  WARN saveError ENOENT: no such file or directory, open 'c:\package.json'
2023-01-31T00:11:42.127Z [err] npm 
2023-01-31T00:11:42.127Z [err] WARN enoent ENOENT: no such file or directory, open 'c:\package.json'
2023-01-31T00:11:42.133Z [err] npm WARN
2023-01-31T00:11:42.133Z [err]  !invalid#1 No description
2023-01-31T00:11:42.145Z [err] npm WARN !invalid#1 No repository field.
2023-01-31T00:11:42.151Z [err] npm WARN
2023-01-31T00:11:42.151Z [err]  !invalid#1 No README data
2023-01-31T00:11:42.160Z [err] npm WARN
2023-01-31T00:11:42.160Z [err]  !invalid#1 No license field.
2023-01-31T00:11:42.160Z [err] 
2023-01-31T00:11:42.161Z [out] + node-red-dashboard@3.3.1
2023-01-31T00:11:42.161Z [out] updated 1 package in 1.394s
2023-01-31T00:11:42.184Z rc=0

It again seems to be trying to do things at the root, rather than in the home directory.

OK, I think we are making progress though it may not seem like it :slight_smile:

Next step is to uninstall Node.js. So stop node-red, uninstall node.js. Make sure after uninstall that there is nothing left of npm, especially the cache. reboot just to be safe. Then reinstall node.js v18 from the official installer. Make sure you include the build tools.

I've actually already tried that (including killing the npm_cache directory, etc.). I got the exact same results as before. Tried installing v18 both via elevated and non-elevated prompts. Same results either way.

I've since moved back to v14.7.6 to see if that fixed things but it hasn't solved the problem.

I can do it all again if you like, but I don't see much reason.

Other thoughts?

Not much left in the noggin I'm afraid. Work-arounds only, no solutions. The main work-around would be to use WSL.

At this point I'm just going to use the CLI install method. It seems to work and I don't really need this system to be fully operational. It's just for my presentation later this week.

I do have one other odd behavior, in case this sparks any ideas. If I install node-red-node-ui-iframe and put an iframe object in the UI, it causes the UI to reset to the default theme and displays ONLY the single iframe, nothing else, not even other tabs are shown. As soon as I remove the iframe, it all goes back to normal.

Weird, huh?

And, of course, this same iframe with the same content works just fine on my Pi instance so I'm confident it isn't an issue with the iframe content itself.

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