'Facing several errors using npm

I first tried installing React using create-react-app, and at that time, it showed me some warnings. I ignored them at that time and started working on my project. Then, recently I tried to deploy my react app to github pages, and was facing errors again!

First, I got:

new MiniCssExtractPlugin({
^


MiniCssExtractPlugin is not a constructor

I used this: npm i -D --save-exact [email protected] to change the version and got away with the error, but when running npm run deploy again, I got this error:

Creating an optimized production build...
Failed to compile.

The target environment doesn't support dynamic import() syntax so it's not possible to use 
external type 'module' within a script

I don't understand what this really means and it also doesn't show any line reference from which the error was causing.

Well, after that, I thought that something was wrong with my project and tried to start another react project. I used npx create-react-app react-deploy to see if this app would deploy to github pages. But, it didn't install and showed me this:

npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')
npm ERR! Cannot read properties of undefined (reading 'isServer')

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ZAS\AppData\Local\npm-cache\_logs\2022-02-02T08_01_49_556Z-debug.log

Aborting installation.
  npm install --no-audit --save --save-exact --loglevel error react react-dom react-scripts 
  cra-template has failed.

Deleting generated file... package.json
Deleting test-deploy/ from C:\Users\ZAS\Desktop\Web\React Start\react-deploy
Done.

I'm farely new to React and Node.js/npm and now, I'm really frustrated due to all of these errors. My node version is 16.13.0 and npm's: 8.1.0

Should I install the older version of node from scratch or not?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source