npm install error: npm ERR! JSON.parse Failed to parse json

foreword

Use the npm install command in the cmd window and report an error:
insert image description here

solve

Judging from the error result, it should be that there is a problem parsing the Json file, so find the package.json file under the green box path, open the json file with vscode, and find that the file is empty, so:

  • Use the command initialization to automatically generate the package.json file
npm init -y 

insert image description here

  • execute the command again
npm install

insert image description here

  • The warning message shows that the package.json file is not fully configured, so we can add it manually:
    insert image description here

  • Excuting an order

npm install

Successful installation:
insert image description here

Guess you like

Origin blog.csdn.net/Junehhh/article/details/130264959