Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install gets the error "must provide string spec"

I try to execute an old react app which is created by myself two years ago. When I try to run the app via "npm install", I've got the following error:

npm ERR! must provide string spec
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\tws80\AppData\Local\npm-cache\_logs\2022-01-09T21_00_13_180Z-debug.log

The dependencies of my package.json file:

  "dependencies": {
    "@material-ui/core": "^4.9.7",
    "@material-ui/icons": "^4.9.1",
    "@mdi/js": "^5.0.45",
    "@mdi/react": "^1.3.0",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.4.1",
    "@testing-library/user-event": "^7.2.1",
    "editor.formatOnPaste": true,
    "editor.formatOnSave": true,
    "husky": "^4.2.3",
    "i18next": "^19.3.3",
    "lint-staged": "^10.0.8",
    "prettier": "^1.19.1",
    "react": "^17.0.2",
    "react-dom": "^17.0.2", 
    "react-html-email": "^3.0.0",
    "react-i18next": "^11.3.3",
    "react-intl": "^4.1.1",
    "react-router-dom": "^5.1.2",
    "react-scripts": "^5.0.0"
  }

My current node and npm version:

node -v v16.13.1
npm -v 8.1.2

I suppose this error is due to the old dependencies but I don't find any useful workaround to solve this problem. After I've removed node_modules I still can re-install node_modules. Thank you for your help.

like image 296
Kai-Chun Lin Avatar asked Sep 10 '25 17:09

Kai-Chun Lin


1 Answers

Running rm -rf node_modules && rm -f package-lock.json && npm i in a bash terminal fixed it for me.

Running npm -v yields --> 8.3.0 on my local machine

like image 153
Erik Grosskurth Avatar answered Sep 12 '25 09:09

Erik Grosskurth