Erreur lors de l'installation de node-red sur Windows

Bonjour,
Je suis sous Windows et j'ai essayé d'installer node-red via node.js directement. Sauf que lorsque je lance l'installation j'obtiens des erreurs (ci dessous). La version de node est 17.9.0 et celle de npm est 8.6.0

node:internal/fs/utils:345
    throw err;
    ^

Error: EPERM: operation not permitted, mkdir 'C:\Users\cardr\.node-red'
    at Object.mkdirSync (node:fs:1350:3)
    at module.exports.makeDirSync (C:\Users\cardr\AppData\Roaming\npm\node_modules\node-red\node_modules\fs-extra\lib\mkdirs\make-dir.js:23:13)
    at handleFilterAndCopy (C:\Users\cardr\AppData\Roaming\npm\node_modules\node-red\node_modules\fs-extra\lib\copy-sync\copy-sync.js:32:35)
    at Object.copySync (C:\Users\cardr\AppData\Roaming\npm\node_modules\node-red\node_modules\fs-extra\lib\copy-sync\copy-sync.js:26:10)
    at Object.<anonymous> (C:\Users\cardr\AppData\Roaming\npm\node_modules\node-red\red.js:125:20)
    at Module._compile (node:internal/modules/cjs/loader:1099:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
  errno: -4048,
  syscall: 'mkdir',
  code: 'EPERM',
  path: 'C:\\Users\\cardr\\.node-red'
}
Node.js v17.9.0

Je suis nouvelle dans ce domaine, si vous avez une solution merci pour votre aide!

I think that the latest officially supported version of node.js is 16. Odd numbered versions are often considered development or at least have short lifespans and not generally recommended for live use.

How are you installing node-red? What is the process and where are you installing it? Are you using a global install? Are you using sudo?

If you are installing locally rather than globally, have you looked at my alternate installer repo on GitHub, that gives some clues as to the correct method.

Merci pour votre réponse!
J'ai aussi essayé avec la version 16 mais cela me donne les mêmes erreurs.
Pour installer node-red je télécharge le node.js, j’exécute le téléchargement, ensuite j'utilise
npm install -g --unsafe-perm node-red
dans mon invité de commande (cela me donne déjà des erreurs) et je met ensuite
|``node-red``` qui me donne aussi des erreurs. Je n'utilise pas sudo, et oui je l'installe localement.
Je vais consulter votre alternatif sur GitHub, avez-vous un lien?

There is a permissions issue.

Check the permissions on C:\Users\cardr\.node-red include read & write for user cardr

Merci pour votre réponse mais ça ne change rien.

C:\Users\cardr>npm install -g --unsafe-perm node-red

changed 301 packages, and audited 302 packages in 14s

31 packages are looking for funding
  run `npm fund` for details

3 high severity vulnerabilities

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.

That install looks normal. What happens when you run node-red?

cela me donne:

C:\Users\cardr>node-red
15 Apr 11:24:01 - [warn] Flushing file C:\Users\cardr\.node-red\package.json to disk failed : Error: EPERM: operation not permitted, rename 'C:\Users\cardr\.node-red\package.json.$$$' -> 'C:\Users\cardr\.node-red\package.json'
15 Apr 11:24:01 - [error] Failed to start server:
15 Apr 11:24:01 - [error] Error: EPERM: operation not permitted, rename 'C:\Users\cardr\.node-red\package.json.$$$' -> 'C:\Users\cardr\.node-red\package.json'

I suggest you restart the computer, delete (or rename) the folder C:\Users\cardr\.node-red then try launching node-red once more.

There is something wrong with the permissions on that folder or the files within that folder. Deleting it will cause it to be recreated when you run node red once more. If you have important files or flows inside of the C:\Users\cardr\.node-red folder, make sure you back them up before you delete it.

J'ai enfin réussi à executer node.red, je me suis rendu compte que package.json, .config.nodes.json, config.users.json, .config.runtime.json
arrivé sous la forme package.json.$$$, config.nodes.json.$$$, config.users.json.$$$, config.runtime.json.$$$je les ai donc renommé.
Cela est étrange.
Merci pour votre aide!

That command installs node-red globally not locally. Sorry, missed that you were on Windows. Do you run that command from an elevated command prompt? (Hint: you shouldn't if you are).

The fact that you can't use the node-red command I think indicates that the install hasn't done what you think. To be honest though, I never install node-red with -g (global) except for testing. and I never use the node-red command so I'm not sure how that works on Windows.

Installing locally means not using the -g. This is a more normal style of node.js app installation. You create a folder cd into the folder and then npm install node-red --production --unsafe-perm. You then use the usual ~/.node-red userDir folder if you like but I prefer to create a userDir folder which I normally call data as a sub-folder of where I've installed node-red. This keeps everything in 1 place and makes it all both easy to remember, easy to find and easy to back up. OCD at its finest! :slight_smile: It also means that you can easily create multiple instances of node-red with different versions of node-red itself - great for testing. The final potential advantage is that the location and running only need standard user accounts and don't accidentally give root access. So I also run my live home automation server the same way.

That is just some helpers, mainly a script and some template files. It isn't meant to be a complete solution, just makes it a bit easier to be consistent. It uses the rules I've just described.

Great, thank you for your very complete answer, I admit that this technology is a bit beyond me, but it helps me! And I find that there is a lot of mutual aid at this level!
Thank you again for your answers.

1 Like