Avatar of Tom Knowlton
Tom Knowlton
Flag for United States of America asked on

ReactJS with Node - 'MODULE_NOT_FOUND after npm create-react-app

Brand new to ReactJS and NodeJS:

Trying to follow this tutorial and getting this error:

TUTORIAL:

https://www.taniarascia.com/getting-started-with-react/

ERROR:
C:\Users\ENDER\Desktop\my-app>npm start

> my-app@0.1.0 start
> react-scripts start

internal/modules/cjs/loader.js:463
  throw e;
  ^

Error: Package exports for 'C:\Users\ENDER\Desktop\my-app\node_modules\postcss-safe-parser\node_modules\postcss' do not define a valid '.' target
    at resolveExportsTarget (internal/modules/cjs/loader.js:460:13)
    at resolveExports (internal/modules/cjs/loader.js:393:16)
    at Function.Module._findPath (internal/modules/cjs/loader.js:492:20)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:787:27)
    at Function.Module._load (internal/modules/cjs/loader.js:693:27)
    at Module.require (internal/modules/cjs/loader.js:864:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (C:\Users\ENDER\Desktop\my-app\node_modules\postcss-safe-parser\lib\safe-parse.js:1:17)
    at Module._compile (internal/modules/cjs/loader.js:971:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1011:10) {
  code: 'MODULE_NOT_FOUND'
}

C:\Users\ENDER\Desktop\my-app>

Open in new window

Just wondering if you can tell me what's wrong, or point me in the right direction... thx.
Node.jsReactJavaScript

Avatar of undefined
Last Comment
Tom Knowlton

8/22/2022 - Mon
leakim971

probably it fail loading something at a point, so restart from scratch...
Tom Knowlton

ASKER
you mean run

"npm create-react-app"

with a new folder name?


That's fine and I can try that - but isn't there a way to troubleshoot this problem?  I mean, I'm going to have to learn how to do it eventually.  I was just hoping for some advice on where to check.

For example, would npm audit fix --force work?  Or is that a waste of time?
Tom Knowlton

ASKER
erm .. I guess it would be npx not npm...
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Tom Knowlton

ASKER
Okay -- I ran create-react-app new-app and it created the environment inside of the folder named "new-app" just fine...

but still the same problem as I orginally posted.

C:\Users\ENDER\Desktop\new-app>dir
 Volume in drive C is WINDOWS
 Volume Serial Number is 7E73-7DF1

 Directory of C:\Users\ENDER\Desktop\new-app

05/25/2021  05:03 PM    <DIR>          .
05/25/2021  05:03 PM    <DIR>          ..
10/26/1985  02:15 AM               310 .gitignore
05/25/2021  05:03 PM    <DIR>          node_modules
05/25/2021  05:03 PM         1,525,095 package-lock.json
05/25/2021  05:03 PM               810 package.json
05/25/2021  05:03 PM    <DIR>          public
10/26/1985  02:15 AM             3,369 README.md
05/25/2021  05:03 PM    <DIR>          src
               4 File(s)      1,529,584 bytes
               5 Dir(s)  627,183,935,488 bytes free

C:\Users\ENDER\Desktop\new-app>

Open in new window

Tom Knowlton

ASKER
Contents of file safe-parse.js:

let { Input } = require('postcss')

let SafeParser = require('./safe-parser')

module.exports = function safeParse (css, opts) {
  let input = new Input(css, opts)

  let parser = new SafeParser(input)
  parser.parse()

  return parser.root
}

Open in new window

  as per the error message:

C:\Users\ENDER\Desktop\new-app>npm start

> new-app@0.1.0 start
> react-scripts start

internal/modules/cjs/loader.js:463
  throw e;
  ^

Error: Package exports for 'C:\Users\ENDER\Desktop\new-app\node_modules\postcss-safe-parser\node_modules\postcss' do not define a valid '.' target
    at resolveExportsTarget (internal/modules/cjs/loader.js:460:13)
    at resolveExports (internal/modules/cjs/loader.js:393:16)
    at Function.Module._findPath (internal/modules/cjs/loader.js:492:20)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:787:27)
    at Function.Module._load (internal/modules/cjs/loader.js:693:27)
    at Module.require (internal/modules/cjs/loader.js:864:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (C:\Users\ENDER\Desktop\new-app\node_modules\postcss-safe-parser\lib\safe-parse.js:1:17)
    at Module._compile (internal/modules/cjs/loader.js:971:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1011:10) {
  code: 'MODULE_NOT_FOUND'
}

C:\Users\ENDER\Desktop\new-app>

Open in new window


ASKER CERTIFIED SOLUTION
Julian Hansen

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Tom Knowlton

ASKER
Node version was 13.x

now it is:

14.17.0

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Tom Knowlton

ASKER
It works now