簡體   English   中英

使用 npm-start 為 React 應用程序啟動開發服務器時出錯

[英]An error with starting a dev server for React app using npm-start

我使用 npx create-react-app myapp 創建了一個反應應用程序。 npm start 不會啟動開發者服務器。 我已經嘗試重新安裝 node_modules 但它沒有用。 我使用最新版本的 React 和 Node Package Manager。

錯誤:

     Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
     - configuration.module.rules[2].oneOf[1].include should be one of these:
       RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? } | [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
       -> One or multiple rule conditions
       Details:
        * configuration.module.rules[1].include should be an instance of RegExp
        * configuration.module.rules[1].include: The provided value "E:\\!!Netbeans\\!React js tutorial\\my-app\\src" contains exclamation mark (!) which is not allowed because it's reserved for loader syntax.
        * configuration.module.rules[1].include should be an instance of function
        * configuration.module.rules[1].include should be an array:
          [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
        * configuration.module.rules[1].include should be an object.
        * configuration.module.rules[1].include should be an array:
  [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
        * configuration.module.rules[2].oneOf[1].include should be an instance of RegExp
        * configuration.module.rules[2].oneOf[1].include: The provided value "E:\\!!Netbeans\\!React js tutorial\\my-app\\src" contains exclamation mark (!) which is not allowed because it's reserved for loader syntax.
        * configuration.module.rules[2].oneOf[1].include should be an instance of function
        * configuration.module.rules[2].oneOf[1].include should be an array:
  [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]
        * configuration.module.rules[2].oneOf[1].include should be an object.
        * configuration.module.rules[2].oneOf[1].include should be an array:
          [RegExp | string | function | [(recursive)] | object { and?, exclude?, include?, not?, or?, test? }]

    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! my-app@0.1.0 start: `react-scripts start`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the my-app@0.1.0 start script.
    npm ERR! This is probably not a problem with npm. There is likely                 additional logging output above.
    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\Users\Сергей\AppData\Roaming\npm-cache\_logs\2019-06-04T14_34_52_240Z-debug.log

我試圖重新安裝 node_modules 但它沒有用。 請幫我!

Package.json 文件:

    {
      "name": "myapp",
      "version": "0.1.0",
      "private": true,
      "dependencies": {
        "react": "^16.8.6",
        "react-dom": "^16.8.6",
        "react-scripts": "3.0.1"
      },
      "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",
          "last 1 firefox version",
          "last 1 safari version"
        ]
      }
    }

我遇到了同樣的問題,但從目錄(文件夾)中刪除感嘆號對我有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM