简体   繁体   English

我无法使用 npm 开始运行反应应用程序如何解决此错误?

[英]i can't run react app using npm start how to fix this error?

Failed to compile

./src/index.js 1:39 Module parse failed: Unexpected token (1:39) File was processed with these loaders: ./src/index.js 1:39 模块解析失败:意外的令牌 (1:39) 使用这些加载器处理了文件:

  • ./node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js ./node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js
  • ./node_modules/babel-loader/lib/index.js You may need an additional loader to handle the result of these loaders. ./node_modules/babel-loader/lib/index.js 你可能需要一个额外的加载器来处理这些加载器的结果。

$RefreshRuntime$ = require('C:/Users/I'm-cx0140/Desktop/dreact/node_modules/react-refresh/runtime.js'); $RefreshRuntime$ = require('C:/Users/I'm-cx0140/Desktop/dreact/node_modules/react-refresh/runtime.js'); | | $RefreshSetup$(module.id); $RefreshSetup$(module.id); | | This error occurred during the build time and cannot be dismiss此错误发生在构建期间,无法关闭

my package.json我的 package.json

{
  "name": "myapp",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.13.0",
    "@testing-library/react": "^11.2.7",
    "@testing-library/user-event": "^12.8.3",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "4.0.3",
    "web-vitals": "^1.1.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

    enter code here
{
  "name": "myapp",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.13.0",
    "@testing-library/react": "^11.2.7",
    "@testing-library/user-event": "^12.8.3",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "4.0.3",
    "web-vitals": "^1.1.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Removing the " ' " from my foldername work for me.从我的文件夹名中删除“'”对我有用。 change I'm-cx0140 to something like Im-cx0140将 I'm-cx0140 更改为类似 Im-cx0140

The ' character in your user name (I'm-cx0140) can trigger this issue, create your project in another folder.您的用户名(I'm-cx0140)中的 ' 字符可能会触发此问题,请在另一个文件夹中创建您的项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM