For a simple Create React App https://create-react-app.dev
project, I run npm install
.
Then npm start
opens the default web browser1.
Pressing F12 displays two error messages in the console.
错误消息是:
-
Uncaught ReferenceError: process is not defined
, and
-
Line 0: Parsing error: ImportDeclaration should appear when the mode is ES6 and in the module context
.
我应该做什么来纠正这些错误?
我在其他地方看到过这些错误,有时指的是version中的软件包问题package.json
.
请参阅下面的参考列表。
我相信参考文献3-6可能与这里的问题有关。
The .eslintrc.json
and package.json
files are provided below.
But since they will hardly be sufficient to reproduce the error,
here is a link to
a zip file containing all the necessary project files http://user.it.uu.se/%7Ehesc0353/Q71335760.zip.
2
.eslintrc.json
:
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
"no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
]
}
}
package.json
:
{
"name": "Uncaught ReferenceError",
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.4.1",
"@testing-library/user-event": "^7.2.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version"
]
},
"devDependencies": {
"eslint": "^7.32.0",
"eslint-plugin-react": "^7.29.2"
}
}
参考
- 创建 React 应用程序 (CRA) https://create-react-app.dev
- 包含所需项目文件的 Zip 文件 http://user.it.uu.se/%7Ehesc0353/Q71335760.zip
- React Uncaught ReferenceError:进程未定义 https://stackoverflow.com/q/70368760
- 热重载时未定义进程 https://stackoverflow.com/q/70357360
- 第 0 行:解析错误:无法读取未定义的属性“map” https://stackoverflow.com/q/62079477
- React Typescript:第 0 行:解析错误:无法读取属性
未定义的“名称” https://stackoverflow.com/q/60729199
1
In my case Google Chrome Version 98.0.4758.102, 64-bit.
Running on Windows 10.
2
Install the project (locally) by running npm install
– this may
take about 5-9 minutes.
Then run npm start
to open the project in the default web browser.