I accidentally delete the "invisible" directory ".npm" in my home directory (even include package.json) on my ubuntu webserver
And I still got an Node.js website running (it's under /var/www/)
So how do I do to check my npm's status or how do I rebuild it?
Now my site seems working fine but I am so afraid that it will die after I restart something else...
Thanks for your help in advance, and sorry for my stupidity...
Down below is some feedback that npm gave me
root@localhost:/home/alex# npm restart
npm ERR! Linux 4.15.0-112-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "restart"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! path /home/alex/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/home/alex/package.json'
npm ERR! enoent ENOENT: no such file or directory, open '/home/alex/package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /home/alex/npm-debug.log
root@localhost:/home/alex# npm install
npm WARN enoent ENOENT: no such file or directory, open '/home/alex/package.json'
npm WARN alex No description
npm WARN alex No repository field.
npm WARN alex No README data
npm WARN alex No license field.
The .npm
directory is a cache so deleting it shouldn't affect anything running on your system.
The missing package.json
file is a bigger deal potentially, but I suspect you are simply in the wrong directory. One typically doesn't have a package.json
at the root level of their home directory (in your case, /home/alex
). If I'm right about that, then the answer is to find out where the real package.json
is.
If on the other hand, it really was in your home directory, and you don't have a backup of your home directory, then you'll need to regenerate it however you managed to create it in the first place. (And while you're at it, create a backup system so you're not in this situation again!)
I also see you are running Node.js 8.x. That version of Node.js was last supported in 2019. You are running a version of Node.js with known TLS/SSL vulnerabilities. Update to 12.x at least, and preferably 14.x.