When trying to create a new Standalone Javascript React Project in Visual Studios 2020, as I have many times before on other computers, I am getting this Error that it can't find package.json.
I have tried npm init, npm uninstall then reinstall, also uninstalling and reinstalling create-react-app.
I have tried this in my main folder and at path C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE
To try and create package.json all with no success.
This should just default create, any ideas?
Edit: It creates this empty project Empty Project Also if I separately use npx create-react-app it works fine.
CodePudding user response:
Ok, I didn't quite understand your problem but try this.
First,
npm init -y
in the terminal. This will create a package.json file.
Second, create an index.js file in the same directory where you type in your code.
Third, Go to package.json file and add a script
"start":"node index.js"
then, go to the terminal and typenpm start
. or, you can just donode index.js
in the terminal without adding script in package.json.
CodePudding user response:
To get it to work I found where one of the package.json files was and copy and pasted it to C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE. For now, it seems to be working if anyone comes behind me and gets as fed up as I have.