Error to Install Node Home Assistant

HI,

I'm trying to install node-red-contrib-home-assistant and it has the following error:

pi@raspberrypi:~ $ sudo npm install node-red-contrib-home-assistant
npm ERR! code 128
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b 0.18.2 git://github.com/node-red/node-red.git /root/.npm /_cacache/tmp/git-clone-d1cbe3f3
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-d1cbe3f3': Permission den ied
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-07-08T03_44_46_545Z-debug.log

Anyone have any idea what might be happening?

I not use Hass.io.

My HA is running in raspbian.

Please find the node on flows.nodered.org and follow the instructions to install

I followed the steps in the link but it did not work.
Give the error I posted here.

Really?
Your original post shows you are logged in as the user pi.
If you followed the command as per the readme, it shouldn't be trying to write to /root/.npm

Please post the commands and responses here

I already tried to install directly by the node red and also by the terminal.
But both are failing.

pi@raspberrypi:~ $ sudo npm install node-red-contrib-home-assistant
npm ERR! code 128
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b 0.18.2 git://github.com/node-red/node-red.git /root/.npm/_cacache/tmp/git-clone-e7cad51d
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-e7cad51d': Permission denied
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-07-08T17_22_54_070Z-debug.log

No that's the same command you ran first time, and isn't the list of commands as per the ReadMe.

it also doesn't look like you are in the .node-red directory when you issue the NPM command. When you loginto the pi you should issue a cd .node-red and then the npm command

and the command to use (not the one listed above -twice) and to cd .node-red is listed in the ReadMe…