eM Jay
eM Jay

Reputation: 43

Error when typing "npm start" in visual studio using react.js

PS C:\Users\PC1\Downloads\portfolio_website-STARTER> npm start

> [email protected] start C:\Users\PC1\Downloads\portfolio_website-STARTER
> node index.js

internal/modules/cjs/loader.js:892
  throw err;
  ^

Error: Cannot find module 'C:\Users\PC1\Downloads\portfolio_website-STARTER\index.js'  
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)        
    at Function.Module._load (internal/modules/cjs/loader.js:745:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\PC1\AppData\Roaming\npm-cache\_logs\2021-09-05T22_40_19_833Z-debug.log
PS C:\Users\PC1\Downloads\portfolio_website-STARTER>

The error shown above happens when I try to run npm start to start the virtual host.

I have tried the following:

  1. Updated node.js to the latest version.
  2. Went to package.json under scripts and added "start": "node index.js".

Upvotes: 2

Views: 147

Answers (2)

Ezani
Ezani

Reputation: 555

First make sure your startup file is index.js in your package.json file and make sure you have index.js in your project.

Upvotes: 0

fernandomatiasdv
fernandomatiasdv

Reputation: 81

first, do you install the dependencies? (npm i) Then, exists index.js file in the portfolio_website-STARTER folder?

Upvotes: 1

Related Questions