Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

All npm commands giving same error (ENOENT)

I'm using windows 8.1 x64 with all updates.

I was using nodejs 8.9.1 - I took an error on command "npm -v".
So I uninstalled this version and install 8.9.3. It gave me same error on the command.
And then I uninstalled 8.9.3 and clean all paths using this answer; https://stackoverflow.com/a/20711410/1143249 Then installed new version 9.3.0...

But still, I'm getting same error in all npm commands.
What am I missing? How can I solve this problem?

C:\Users\UserName\Desktop>npm -v
Error: spawn C:\Program Files\nodejs\node.exe ENOENT
    at _errnoException (util.js:999:13)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:201:19)
    at onErrorNT (internal/child_process.js:389:16)
    at process._tickCallback (internal/process/next_tick.js:152:19)
    at Function.Module.runMain (module.js:703:11)
    at startup (bootstrap_node.js:194:16)
    at bootstrap_node.js:618:3
C:\Program Files\nodejs\node_modules\npm\lib\npm.js:51
      throw new Error('npm.load() required')
      ^

Error: npm.load() required
    at Object.get (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:51:13)
    at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
    at process.emit (events.js:159:13)
    at process._fatalException (bootstrap_node.js:387:26)
5.5.1

events.js:136
      throw er; // Unhandled 'error' event
      ^

Error: spawn C:\Program Files\nodejs\node.exe ENOENT
    at _errnoException (util.js:999:13)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:201:19)
    at onErrorNT (internal/child_process.js:389:16)
    at process._tickCallback (internal/process/next_tick.js:152:19)
    at Function.Module.runMain (module.js:703:11)
    at startup (bootstrap_node.js:194:16)
    at bootstrap_node.js:618:3

Update:
Everytime I uninstalled nodejs, clean/delete folders and tried these versions;
- node-v9.3.0-x64 not working
- node-v8.9.3-x64 not working
- node-v8.9.1-x64 not working
- node-v8.9.0-x64 not working
- node-v7.10.0-x64 shows version number also a small error.
Here is the output;

C:\Users\UserName\Desktop>npm -v
5.6.0

events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: spawn C:\Program Files\nodejs\node.exe ENOENT
    at exports._errnoException (util.js:1050:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:367:16)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
    at Module.runMain (module.js:607:11)
    at run (bootstrap_node.js:427:7)
    at startup (bootstrap_node.js:151:9)
    at bootstrap_node.js:542:3

Update:
I uninstalled Avg anti-virus protection and installed node-v6.12.3-x64.msi. Still I have problems, an example; I can't run commands like; Node v6.12.3 on Windows 8.1 x64

Last Update
Thanks for all answers ( until this date: 10.02.2018 03:30 PM GTM+3 )
( I've completed some of my jobs with vm windows until this date but now I've sad news.)
I ran out all options and I have still a lot work to do with npm packages. So, I've formatted my machine and replace with Windows 10 Enterprise x64. I can't try new answers now but here is golden point what I've learned; If you have mission critical machine like ci-build (jenkins etc.) or if you don't have more than one computer (And vm is not an option) Just backup your drive completely at time to time because you will never know your computer softwares (like node - npm) could give an interesting errors such as this. That's what I learned, just saying...

like image 202
Lost_In_Library Avatar asked Dec 24 '17 16:12

Lost_In_Library


People also ask

What does Enoent mean?

It's an abbreviation of Error NO ENTry (or Error NO ENTity), and can actually be used for more than files/directories. It's abbreviated because C compilers at the dawn of time didn't support more than 8 characters in symbols. edited Jun 4, 2019 at 14:30. community wiki.


2 Answers

The workaround is to ensure that C:\Users\{user}\AppData\Roaming\npm exists and is writable with your normal user account.

see Troubleshooting

like image 132
Gabriel Bleu Avatar answered Sep 20 '22 14:09

Gabriel Bleu


Although haven't tested Node on Windows 8, I suggest you get rid of npm installation under AppData folder altogether. You can achieve this by using a Node version manager. I recommend Nodist. You can easily switch between versions as well.

With Nodist you can run the command as such:

 nodist 6.2.10

One of the things I suspect is Node runtime's limited access to required files under C:/ drive - maybe something related to Windows 8. That said, you could install nodist in any drive other than C:/. Meanwhile as mentioned by @fjoe, stick with LTS versions especially v6.x.x.

like image 32
Ahmad Baktash Hayeri Avatar answered Sep 21 '22 14:09

Ahmad Baktash Hayeri