使用npm-start启动React应用的开发服务器时出错

时间:2019-06-05 06:34:41

标签: javascript reactjs npm npm-start

我使用npx create-react-app myapp创建了一个React应用程序。 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"
        ]
      }
    }

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,但是从目录(文件夹)中删除感叹号对我来说是可行的。