react icon indicating copy to clipboard operation
react copied to clipboard

I am encountering an error when trying to run the command npm run dev. How can I resolve

Open reacterpro opened this issue 1 year ago • 5 comments

I utilized vite to create a frontend template. The package.json resides in the frontend directory and includes development tools, but I'm encountering an error. This project involves Django and React. I am using a Python virtual environment, and the backend is running smoothly. I have also installed React dependencies in the environment, so I am unsure of what the issue could be.

{
  "name": "frontend",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
    "preview": "vite preview"
  },
  "dependencies": {
    "axios": "^1.6.8",
    "jwt-decode": "^4.0.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-router-dom": "^6.22.3",
    "react-scripts": "^3.0.1"
  },
  "devDependencies": {
    "@types/react": "^18.2.66",
    "@types/react-dom": "^18.2.22",
    "@vitejs/plugin-react": "^4.2.1",
    "eslint": "^8.57.0",
    "eslint-plugin-react": "^7.34.1",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-refresh": "^0.4.6",
    "vite": "^5.2.0"
  }
}

error:

(env) PS C:\Users\Abdul\Documents\Personal Projects\API-test\Django&React FS\frontend> npm run dev

> <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7117031e1f05141f1531415f415f41">[email protected]</a> dev
> vite

'React' is not recognized as an internal or external command,
operable program or batch file.
node:internal/modules/cjs/loader:1146
  throw err;
  ^

Error: Cannot find module 'C:\Users\Abdul\Documents\Personal Projects\API-test\vite\bin\vite.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
    at Module._load (node:internal/modules/cjs/loader:984:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.12.1
(env) PS C:\Users\Abdul\Documents\Personal Projects\API-test\Django&React FS\frontend>

Try https://reacter.space/questions/i-am-encountering-an-error-when-trying-to-run-the-command-npm-run-dev-how-can-i-resolve

reacterpro avatar Sep 04 '24 09:09 reacterpro

Did you run npm install before running the project if not run npm install. If already installed delete node modules folder and rerun npm install

kapilkumarfuture avatar Sep 04 '24 12:09 kapilkumarfuture

Run npm commands in correct file. Run npm install inside your project folder

VDXD avatar Sep 04 '24 17:09 VDXD

built an app to get paid for this PR https://www.n0va-io.com/discover/facebook/react

nkalpakis21 avatar Sep 05 '24 03:09 nkalpakis21

It seems your node packages aren't installed properly, or aren't installed at all.

You should try deleting node_modules folder if there is any then run npm install in your project directory then you can retry your npm run dev command.

Felixdiamond avatar Sep 10 '24 08:09 Felixdiamond

you should try to delete the node_modules folder and then run the npm i in your project, after that run the npm run dev

amanmobikasa avatar Sep 13 '24 07:09 amanmobikasa

``1. Check React Installation 2.Remove react-scripts (If Using Vite) 3. Reinstall Node Modules 4. Ensure Vite is Installed Properly 5. Check for Correct Scripts in package.json 6. Vite Configuration File 7. Check Node.js Version 8. Clear npm Cache (if needed)

sidhanshamil avatar Sep 18 '24 15:09 sidhanshamil

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

github-actions[bot] avatar Dec 17 '24 16:12 github-actions[bot]

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!

github-actions[bot] avatar Dec 24 '24 17:12 github-actions[bot]