I am having the following code that gives me an error "SyntaxError: Cannot use import statement outside a module" and it points to the first row of the file: import React, {createContext} from 'react';
import React, {createContext} from 'react';
const UserContext = React.createContext({
isLoggedIn: false,
UID: '',
setUID: () => {},
login: () => {},
logout: () => {}
});
export default UserContext;
I have tried to add "type": "module" to my package.json but it causes a new error "ReferenceError: require is not defined" that points to my app.js file to the row "const express = require('express')". I have also tried to change the file name from UserContext.js to UserContext.mjs but it didn't solve the problem. What can I do to fix this problem?