[RESOLVED] Ubuntu npm install error

New to linux and don’t know how to fix.

Please help

Looks like you’re using node 18. I think you may need to use 14, that’s what I’m using.

How do I do that? When I run the cmd to set the version I get:

drmedic@minecraft:/$ sudo curl -sL https://deb.nodesource.com/setup_14.x | bash -

##. Installing the NodeSource Node.js 14.x repo…

##. Populating apt-get cache…

+. apt-get update
Reading package lists… Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
Error executing command, exiting

(put periods to stop formating)

I don’t think the sudo is being respected after the pipe. Try changing the bash bit to have sudo as well.

1 Like

That worked but is still installing node v18.7.0

Edit: I did uninstall and verify it was uninstalled be for reinstalling

The first command ran shows that the curl and bash command worked
Then I did the install
At the end I verified the version and it says v18.7.0

Try and install nvm (node version manager) then you can switch fairly easily.

And sudo npm install doesn’t work

So fixed the npm install by changing the permissions on /minecraft and got it installed and everything ran correctly untill I tried to start mineos and got:

drmedic@minecraft:/usr/games/minecraft$ systemctl start mineos
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to start ‘mineos.service’.
Authenticating as: DrMedic (drmedic)
Job for mineos.service failed because the control process exited with error code.
See “systemctl status mineos.service” and “journalctl -xeu mineos.service” for details.
drmedic@minecraft:/usr/games/minecraft$ systemctl status mineos
× mineos.service - Start MineOS minecraft front-end
Loaded: loaded (/etc/systemd/system/mineos.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Wed 2022-11-30 08:26:23 UTC; 8s ago
Process: 1636 ExecStart=/usr/bin/node service.js start (code=exited, status=203/EXEC)
CPU: 552us

Nov 30 08:26:23 minecraft systemd[1]: mineos.service: Scheduled restart job, restart counter is at 5.
Nov 30 08:26:23 minecraft systemd[1]: Stopped Start MineOS minecraft front-end.
Nov 30 08:26:23 minecraft systemd[1]: mineos.service: Start request repeated too quickly.
Nov 30 08:26:23 minecraft systemd[1]: mineos.service: Failed with result ‘exit-code’.
Nov 30 08:26:23 minecraft systemd[1]: Failed to start Start MineOS minecraft front-end.

Pretty sure usr/games/minecraft should be owned by root:root, change it back if you modified it.
Then sudo npm install —unsafe-perm (check that argument) in that folder, you might not need to do that bit.

Then try and start mineos.

Don’t change things from the guide.

I did what you said and I got an error saying I am missing passport but it’s not allowing me to install it, when I try and do it with sudo npm it say that npm is not a valid command.

I then tried to run mineos to see if it would run anyways and I got a different error:

Delete /usr/games/minecraft
To start over.
Run the guide commands as root - before running the commands do

sudo su

This will have you in terminal as root.
Then install nvm, use nvm to install node 14 - ensure you can run node and its the correct version.

node —version

Once node 14 is installed and working goto /var/games and git clone mineos to minecraft folder and continue the rest of the guide, all done in the root terminal.

I did that and I’m using node v14.21.1, and still getting same error:

So, something I’ve come across (possibly if using nvm) is node not in the correct location for the service.
I think it needs to be accessible in /usr/bin/node
If you type

which node

If it’s not /usr/bin/node you’ll need to create a symlink or something.

Another test method is to go to /var/games/minecraft and execute

node webui.js

If it runs it means it’s more likely the service can’t properly run and likely to be the node location.

Yes that worked it was in /root/.nvm/versions/node/v14.21.1/bin/node
and I had to create a symlink into /usr/bin/node and that fixed it perfectly

Hi, I am very new to linux as well (started today), I don’t know how to make a symlink, I need to do the exact same process as you. I looked up and tried some ways but whenever I use which node I get the same location.

I got this after literally hard linking the proper node version to /usr/bin/node, it was doing this with symlink too so I guess it didn’t make a difference:

diskusage@1.1.3 install /usr/games/minecraft/node_modules/diskusage
node-gyp rebuild

sh: 1: node-gyp: Permission denied
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! diskusage@1.1.3 install: node-gyp rebuild
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the diskusage@1.1.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-12-16T23_34_30_962Z-debug.log

Need to use the unsafe-perm option - should see it on the github page readme

Ok, thank you so much! MineOS is finally running!