Node.js error after installing via dietpi-software Topic is solved

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Post Reply
Mr.Panda
Posts: 16
Joined: Tue Oct 19, 2021 11:11 am

Node.js error after installing via dietpi-software

Post by Mr.Panda »

Hi, I am trying to install node.js and node-red to build my custom node.

But even at the beginning I am getting errors. After installing via dietpi-software, if I run npm doctor, I get the following errors:

Code: Select all

npm WARN checkFilesPermission error getting info for /usr/bin/node_modules
npm WARN checkFilesPermission error getting info for /usr/bin/node_modules/.bin
Check                               Value   Recommendation/Notes
npm ping                            ok
npm -v                              not ok  Use npm v8.1.0
node -v                             ok      current: v16.11.1, recommended: v16.11.1
npm config get registry             ok      using default registry (https://registry.npmjs.org/)
which git                           ok      /usr/bin/git
Perms check on cached files         ok
Perms check on local node_modules   not ok  Check the permissions of files in /usr/bin/node_modules (should be owned by current user)
Perms check on global node_modules  ok
Perms check on local bin folder     not ok  Check the permissions of files in /usr/bin/node_modules/.bin
Perms check on global bin folder    ok
Verify cache contents               ok      verified 347 tarballs

npm ERR! Some problems found. See above for recommendations.
I have played with user permissions but no luck yet. I also tried using nvm as well.
User avatar
Joulinar
Posts: 6525
Joined: Sat Nov 16, 2019 12:49 am

Re: Node.js error after installing via dietpi-software

Post by Joulinar »

Hi,

this might be expected as on DietPi we start NodeRed with a custom user directory /mnt/dietpi_userdata/node-red

This is the start command from the service definition

Code: Select all

ExecStart=/mnt/dietpi_userdata/node-red/node_modules/.bin/node-red -u /mnt/dietpi_userdata/node-red
As well the service is started as own user nodered

I guess you would need to switch into user directory and execute it from there

Code: Select all

cd /mnt/dietpi_userdata/node-red
sudo -u nodered npm doctor

Code: Select all

root@DietPi4:/mnt/dietpi_userdata/node-red# sudo -u nodered npm doctor
Check                               Value  Recommendation/Notes
npm ping                            ok
npm -v                              ok     current: v8.1.0, latest: v8.1.0
node -v                             ok     current: v17.0.0, recommended: v17.0.0
npm config get registry             ok     using default registry (https://registry.npmjs.org/)
which git                           ok     /usr/bin/git
Perms check on cached files         ok
Perms check on local node_modules   ok
Perms check on global node_modules  ok
Perms check on local bin folder     ok
Perms check on global bin folder    ok
Verify cache contents               ok     verified 528 tarballs
root@DietPi4:/mnt/dietpi_userdata/node-red#
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Mr.Panda
Posts: 16
Joined: Tue Oct 19, 2021 11:11 am

Re: Node.js error after installing via dietpi-software

Post by Mr.Panda »

I see, thanks @Joulinar . I am getting the same results now.

However, If I try to install any npm module, I am getting the following error:
Error: EACCES: permission denied, mkdir '/mnt/dietpi_userdata/node-red/node_modules/@abandonware'
As far as I know, installing npm modules with sudo is not also suggested.

How should I proceed?
User avatar
Joulinar
Posts: 6525
Joined: Sat Nov 16, 2019 12:49 am

Re: Node.js error after installing via dietpi-software

Post by Joulinar »

how does permissions looks like

Code: Select all

ls -la /mnt/dietpi_userdata/node-red/node_modules/
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Mr.Panda
Posts: 16
Joined: Tue Oct 19, 2021 11:11 am

Re: Node.js error after installing via dietpi-software

Post by Mr.Panda »

I followed the steps mentioned https://docs.npmjs.com/resolving-eacces ... s-globally.

Now, it works all fine.
User avatar
Joulinar
Posts: 6525
Joined: Sat Nov 16, 2019 12:49 am

Re: Node.js error after installing via dietpi-software

Post by Joulinar »

Means you changed default directory now? I guess we simply could have fixed file system permissions.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Mr.Panda
Posts: 16
Joined: Tue Oct 19, 2021 11:11 am

Re: Node.js error after installing via dietpi-software

Post by Mr.Panda »

Sorry, I missed your post. The permissions are as follows:

Code: Select all

drwxr-xr-x   4 nodered nodered   4096 Oct 20 13:42 node-red
I guess we simply could have fixed file system permissions.
In this discussion, they suggest not the play with user permissions. Also official node.js doc. suggest the same thing.

But do you suggest changing permissions?

Edit: Btw, that fix only applies to when we install nodes globally, not locally.

Could you suggest a permission fix, where I can install global and local nodes without root permission?
User avatar
Joulinar
Posts: 6525
Joined: Sat Nov 16, 2019 12:49 am

Re: Node.js error after installing via dietpi-software

Post by Joulinar »

try to use sudo -u nodered as this will install packages as nodered user and should target directory /mnt/dietpi_userdata/node-red/node_modules/
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Mr.Panda
Posts: 16
Joined: Tue Oct 19, 2021 11:11 am

Re: Node.js error after installing via dietpi-software

Post by Mr.Panda »

Thanks @Joulinar now, it loads to correct place.

However getting a new error as

Code: Select all

[warn] [node-red-contrib-ble-sense/protocols] Error: EAFNOSUPPORT, Address family not supported by protocol
The examples I found are all related to dockers that made me confused. I am digging into this now.

Edit: My npm packages depends on @abandonware/noble.

Edit-2: Apparently, this was because the bluetooth was disabled :cry: , I enabled it and all fine now 8) .

Due to my questions, we kind of moved more on the topic, hence I am accepting @Joulinar's answer that fix the question in the title.
User avatar
Joulinar
Posts: 6525
Joined: Sat Nov 16, 2019 12:49 am

Re: Node.js error after installing via dietpi-software

Post by Joulinar »

yes bluetooth is disabled by default and needs to be enabled manually 8)
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply