Search code examples
node.jsnpmwebpack

How to solve npm error "npm ERR! code ENOENT" after trying ```npm run build```


I am working on a symfony 5 project and i am using Webpack. When a try to run "npm run build", i get this error!

    $ npm run build

> build
> encore production --progress

npm ERR! code ENOENT
npm ERR! syscall spawn C:\Windows\system32\cmd.exe;C:\ssh
npm ERR! path F:\web\nash-cm
npm ERR! errno -4058
npm ERR! enoent spawn C:\Windows\system32\cmd.exe;C:\ssh ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\USER\AppData\Local\npm-cache\_logs\2022-01-26T14_09_13_962Z-debug.log

I did research on it and i fund that i have to first clean the cache whit command npm cache clean, what i have done and delete afeter node_modules folder and package-lock.json, what a have also done and at the end, i have to run npm install, what give me the same error! Can somebody help me?


Solution

  • It is OK now. I found the solution here.

    The problem was that npm was not able to find those two paths C:\Windows\system32\cmd.exe;C:\ssh. they where on a inappropriate environment variable,on ComSpec instead of Path.

    To solve the problem, i deleted them from ComSpec environment variable. what I remember is that npm ERR! code ENOENT is caused by npm's inability to find or read a file. Hope my answer can help somebody else.