You are not logged in.

#1 2017-08-03 19:27:27

TremorAcePV
Member
Registered: 2016-08-24
Posts: 22

npm won't do anything, but can't be killed with ^C.

This is an Arch Linux Container on a Fedora 26 Server.

System Specs:
Linux httpd 4.11.11-300.fc26.x86_64
npm 5.3.0-1
nodejs 8.2.1-1

This container used to live on a Fedora 26 Workstation, but I moved it to a Server by tarring the directory and untarring in the correct location then adjusting the config file.

My issue is that anything I try to do with npm runs, won't give an output, and won't quit unless I open top -> find npm process -> send signal 9 (sigkill). Pressing Ctrl+C is shown but doesn't stop the process. i.e. the following:

[root@httpd ~]# npm run dev
^C^C^C^CKilled
[root@httpd ~]#

Where ^C is my attempts to stop it, Killed is when I go to top and send sigkill to it, and it's supposed to compile some stuff (bootstrap scss) and it doesn't. I've let it sit for over an hour and nothing when before it would do what it needed to in about 15 seconds.

I've done the following as well:

[root@httpd ~]# pacman -Rs nodejs
<prompts I responded Y to>
[root@httpd ~]# pacman -S nodejs
<prompts I responded Y to>

I've tried removing the node_modules folder as well to make sure everything is gone, but this does the same thing npm run dev did (all npm commands do it):

[root@httpd ~]# npm install

Deleted all files this command found:

[root@httpd ~]# find / -name *npm*

Even cleared the pacman cache just in case.

So I'm not sure where to go from here. Even npm help does nothing. Bizarre.

Offline

#2 2017-08-07 14:14:40

TremorAcePV
Member
Registered: 2016-08-24
Posts: 22

Re: npm won't do anything, but can't be killed with ^C.

So after some more testing, I've found that npm won't run as root. It will run as a regular user, but then I have issues with write permissions to the relevant directories.

Checking my bash history, I had originally installed and used npm as root. I'm not sure if updating has caused it to stop working as I have done `pacman -Syu` since then.

Edit:

Now if I do npm -v, it completes but doesn’t return anything. Completes means it doesn't force me to kill the process.

I’m now attempting a reinstall of npm’s modules with npm install, but if I do this with my normal user, it gives output (i.e. a progress bar, scripts running, etc). If I do it with root, it gives nothing and it usually takes a bit, so I can’t be sure it’s not doing stuff.

I wish there were an error log for npm, but all I’ve seen by searching is a module for errors which doesn’t help if the errors are with npm itself.

Frustrating, because I don’t know what changed to let basic commands complete without output.

Last edited by TremorAcePV (2017-08-07 15:54:24)

Offline

#3 2017-08-07 19:19:28

Eschwartz
Bug Wrangler
Registered: 2014-08-08
Posts: 1,163

Re: npm won't do anything, but can't be killed with ^C.

npm runs fine for me, but why aren't you using the npm package from the repos???

Offline

#4 2017-08-09 15:24:16

TremorAcePV
Member
Registered: 2016-08-24
Posts: 22

Re: npm won't do anything, but can't be killed with ^C.

Eschwartz wrote:

npm runs fine for me, but why aren't you using the npm package from the repos???

I don't understand what you mean.

[root@httpd ~]# pacman -Q | grep npm
npm 5.3.0-1

I believe I am using the package from the repos?

If you mean this:

[root@httpd ~]# npm install

I believe that is installing node_modules and not npm itself.

Offline

#5 2017-08-09 21:34:39

Eschwartz
Bug Wrangler
Registered: 2014-08-08
Posts: 1,163

Re: npm won't do anything, but can't be killed with ^C.

TremorAcePV wrote:

Deleted all files this command found:

[root@httpd ~]# find / -name *npm*

Even cleared the pacman cache just in case.

So I'm not sure where to go from here. Even npm help does nothing. Bizarre.

TremorAcePV wrote:

Checking my bash history, I had originally installed and used npm as root. I'm not sure if updating has caused it to stop working as I have done `pacman -Syu` since then.

Tells me that you may have installed npm with pacman, but you have also messed with your npm installation outside of pacman. You shouldn't have any cause to manually delete files, and if "I originally installed npm as root" is something you weren't sure about, then you must not have installed using pacman... because pacman *only* installs as root.

So, what is the output of

type -a npm
pacman -Qkk npm

If you have pacutils installed, you can use `paccheck --file-properties --sha256sum` instead of `pacman -Qkk`

TremorAcePV wrote:
[root@httpd ~]# pacman -Q | grep npm
npm 5.3.0-1

Useless use of grep tongue `pacman -Q npm`

Offline

#6 2017-08-11 14:02:35

TremorAcePV
Member
Registered: 2016-08-24
Posts: 22

Re: npm won't do anything, but can't be killed with ^C.

Eschwartz wrote:

Tells me that you may have installed npm with pacman, but you have also messed with your npm installation outside of pacman. You shouldn't have any cause to manually delete files, and if "I originally installed npm as root" is something you weren't sure about, then you must not have installed using pacman... because pacman *only* installs as root.

Yes, but only in terms of removal. The uncertainty for me was caused by the npm install command. I realize it's installing node_modules, but I'm sure you can see where the confusion comes in there.

Eschwartz wrote:

So, what is the output of

type -a npm
pacman -Qkk npm
[root@httpd ~]# type -a npm
npm is /sbin/npm
npm is /bin/npm
npm is /usr/sbin/npm
npm is /usr/bin/npm
[root@httpd ~]# pacman -Qkk npm
warning: npm: /usr/lib/node_modules/npm (UID mismatch)
warning: npm: /usr/lib/node_modules/npm (GID mismatch)
warning: npm: /usr/lib/node_modules/npm/test (UID mismatch)
warning: npm: /usr/lib/node_modules/npm/test (GID mismatch)
warning: npm: /usr/lib/node_modules/npm/test/fixtures (UID mismatch)
warning: npm: /usr/lib/node_modules/npm/test/fixtures (GID mismatch)
warning: npm: /usr/lib/node_modules/npm/test/fixtures/config (UID mismatch)
warning: npm: /usr/lib/node_modules/npm/test/fixtures/config (GID mismatch)
npm: 4998 total files, 4 altered files

This concerns me because I would assume nuking all npm files I find then using pacman to reinstall should fix any UID/GID problems like that?

I changed the ownership to root for user and group on those files as that was what everything else in the directories had.

Strangely, those files were owned by my user with a group of "nobody". Not sure how that happened.

Eschwartz wrote:

Useless use of grep tongue `pacman -Q npm`

As you can tell, I'm not 100% experienced in use of pacman. When you have a hammer, everything looks like a nail.

Last edited by TremorAcePV (2017-08-11 16:20:51)

Offline

#7 2017-08-11 21:22:15

Eschwartz
Bug Wrangler
Registered: 2014-08-08
Posts: 1,163

Re: npm won't do anything, but can't be killed with ^C.

Well then, that makes more sense. tongue

I'm not sure why you'd have your problem though... like I said, npm works for me (and for lots of other people whose silence testifies on their behalf big_smile).
As for the UID/GID errors, you only deleted the files, not the directories. But I don't think that should cause these errors, even so...

npm should really only be run as your user, but it shouldn't need to try writing to /usr since you aren't supposed to use `npm install -g`

Offline

#8 2017-08-11 21:30:51

TremorAcePV
Member
Registered: 2016-08-24
Posts: 22

Re: npm won't do anything, but can't be killed with ^C.

Eschwartz wrote:

Well then, that makes more sense. tongue

I'm not sure why you'd have your problem though... like I said, npm works for me (and for lots of other people whose silence testifies on their behalf big_smile).
As for the UID/GID errors, you only deleted the files, not the directories. But I don't think that should cause these errors, even so...

npm should really only be run as your user, but it shouldn't need to try writing to /usr since you aren't supposed to use `npm install -g`

Hmm.

So for context, I'm using Laravel (https://laravel.com). I use npm to recompile bootstrap css files. The file structure is essentially /usr/share/webapps/<laravel-directory> which isn't owned by my user. It's owned by http, except for the /usr/share/webapps/<laravel-directory>/node_modules folder which is owned by root because npm was ran as root since my user lacks permissions here.

I'm not sure what the correct permissions would be for this to allow me to use npm safely to recompile these files when changes are made, but also maintain security, and give http access since it needs it. It's been working (running npm as root), and I'm trying to figure out what I did to break it.

I just wish I knew of a way to get a log from npm so I could see why it's locking up when ran as root.

Offline

#9 2017-08-12 21:27:32

TremorAcePV
Member
Registered: 2016-08-24
Posts: 22

Re: npm won't do anything, but can't be killed with ^C.

I've found a workaround for now that isn't a very good one. I essentially

su http

after giving the user a bash shell then do npm things there since it owns the directly I need access to, then undo both those things (i.e. can't login to http anymore once I'm done).

Obviously this isn't the *right* way to do it, but I'm not sure how I'd do it otherwise without root and without breaking or changing permissions in a way that might open security holes. I guess I *could* just add my user to the http group and make everything in the directory g+w, but not sure what the security implications are for that for a website.

Offline

#10 2017-08-13 04:51:38

Eschwartz
Bug Wrangler
Registered: 2014-08-08
Posts: 1,163

Re: npm won't do anything, but can't be killed with ^C.

Well, yes, if you are trying to manage something owned by the http user you will need to update it via the same user. Either via su http, or via sudo -u http

I'm not sure why you think this isn't the right way to do it though. big_smile

(I mean, okay, you might want to make a PKGBUILD for it instead, and install things as your user but using fakeroot to tarball it as the http user for pacman -U to consume.)

Offline

#11 2017-08-14 02:46:38

TremorAcePV
Member
Registered: 2016-08-24
Posts: 22

Re: npm won't do anything, but can't be killed with ^C.

Eschwartz wrote:

Well, yes, if you are trying to manage something owned by the http user you will need to update it via the same user. Either via su http, or via sudo -u http

I'm not sure why you think this isn't the right way to do it though. big_smile

(I mean, okay, you might want to make a PKGBUILD for it instead, and install things as your user but using fakeroot to tarball it as the http user for pacman -U to consume.)

Because, by default, http's shell is /sbin/nologin. So I have to change that to bash to login as http and do things, and when I'm done, I have to change it back, because it's nologin for security reasons.

Using sudo -u http doesn't seem to work when doing npm run dev for example. I get an error about permissions. However, if I actually do change http's shell to bash, then login as http, it works fine.

It's a cumbersome workaround that creates a security hole as long as I don't switch it back. That's why I think it isn't the right way it is meant to be done.

This is why I'd really rather do it via root. While I realize that's a different security concern (running unchecked scripts via root), I trust where they're coming from, so it's less of a concern to me than leaving http open for logins.

Offline

Board footer

Powered by FluxBB