npx create react app Must use import to load ES Module error

npx create react app Must use import to load ES Module error

The error you are receiving is likely due to the fact that your import statement is not correctly formatted. In order for your code to compile correctly, you must use an ES module syntax for importing. Below is an example of a valid import statement for ES module.

import React from 'react';

If you are using a version of React that is lower than 16.6, then you must use the require() syntax instead. Here is an example:

const React = require('react');

It is important to note that you must use either import or require(), but you cannot mix the two. If you are using an older version of React, then you must use require() for all of your imports.

Subscribe to The Poor Coder | Algorithm Solutions

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]
Subscribe