Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Node.JS cannot run npm i in vscode. Constant errors after reinstalling everything

clrcode

New Coder
I have been on this and unable to solve it for over a day.
I don't know what is causing the error(s) but everytime I try to do anything with npm I get error messages.

2 days ago, I noticed my browser was not autorefreshing when I made changes to the code.
ChatGPT suggested to uninstall node and npm and reinstall, which I have done about 10 times.
The errors started after the first time I reinstalled node.js
I then chose to use nvm installer for windows, which worked, but I am still getting errors anytime I try to run anything.
I end up going in circles with gpt everytime trying to solve it.

I am using node version 18.16.0 and npm version 9.5.1

If I open vscode and open a fresh folder in it (add an index.html and script.js)
then run either npm init -y or npm i, i get a host of errors everytime, preventing me from creating the node_modules folder.
it does sometimes create a package.json or package.json locked folder, but I am sure there are probably issues with them.

The errors I get include:
Exception has occurred: Error: ENOENT: no such file or directory, /projectName/git.COM
Exception has occurred: TypeError: Invalid SemVer Range: latest at new Range (this one occurs alot)
Exception has occurred: Error: ENOENT: no such file or directory, open ...current-project\node_modules\acorn\package.json'
Exception has occurred: Error: ENOENT: no such file or directory, "... AppData\Local\npm-cache\_cacache\content-v2\sha512\31\77

Sometimes when running npm i, I will get non stop errors and different errors if I just keep hitting continue in the debugger.

This indicates to me that there is something fundamentally wrong somewhere, (the installation, the ide)
Besides trying to reinstall vscode (which I don't want to do as I have many extensions and configs etc.. installed)
I don't know what to do. This did not happen before when I first installed node.js when starting out around a month ago.
I apologize if I have left some critical details out here, please let me know if / what more I can provide to help.

I'd really appreciate some help here. I am starting a course today and don't want to be left behind.
Thank you.
 
Hi Antero,
Thanks for the suggestion, I have tried that many times, in different orders after creating the package.json folder (npm init -y), no luck unfortunately.

Sometimes it runs npm init -y without (seemingly) an issue, but whenever I try to run npm i, or install any type of node package I run into a host of errors.

After re-installing vscode, node (and npm with it) and removing all of the associated files, (including chocalatey as I installed node from the node website the first few times), all files from programData and programFIles folders - local, roaming I am still continually hitting errors when running any npm i command. Meaning I cannot run react hosted apps through vscode. Live server and the terminal can still run .js files.

Yesterday I tried to rename a file in file explorer, I got the error- (cannot rename as file it open in another program etc..), it was not open anywhere, there is a small glitch in windows 10 apparently with file explorer meaning I had to reopen file explorer to free the process up and rename it. I have also tried restarting the pc many times.

I thought possibly something like that could be the problem but I cannot see any processes in task manager (old vs code, node instances etc..) that obviously should not be open.

I installed nvm manager for windows and have tried using different versions of node.js to no avail.

I have seen this very issue listed elsewhere years ago on github and stackoverflow.
The problem there is that most of the time the discussion is about one single error that gets thrown after running npm i,
which is fine, but in my case, if I hit continue in the debugger, the errors can keep on coming, which suggests to me there
is a conflict, incompatibility issue or miscommunication issue - something more fundamental behind all these errors responsible for causing them. I did not have any of these problems before whenI first installed node.js. As I have tried every method I know or can find to resolve it, I don't know what to do. I am guessing there is a glitch, or some file that has been written incorrectly somewhere down in the weeds.
 

New Threads

Buy us a coffee!

Back
Top Bottom