【问题标题】:React - run dev-server反应 - 运行开发服务器
【发布时间】:2020-03-13 07:39:57
【问题描述】:
  • 在 react 中克隆 git 代码。
  • 安装 npm。

问题 -

由于某种原因,我无法运行 dev-server 。 我在cmd上使用了这两个命令 1. npm 运行开发服务器

我得到的错误之一的“样本” -

警告:在 eslint-plugin-react 设置中未指定 React 版本。看 https://github.com/yannickcr/eslint-plugin-react#configuration 。 C:\Users\Alon\Desktop\skillz_fontend\src\components\Inputs\GooglePlacesInput.jsx 57:30 错误缺少分号分号

  1. npm 开始 -

C:\Users\Alon\Desktop\skillz_fontend>npm start npm ERR!缺少脚本:启动 npm ERR! npm 错误!你是这个意思吗? npm 错误!统计数据 npm 错误!可以在以下位置找到此运行的完整日志:npm ERR!
C:\Users\Alon\AppData\Roaming\npm-cache_logs\2019-11-17T22_59_13_787Z-debug.log

感谢阿隆

【问题讨论】:

    标签: reactjs npm cmd


    【解决方案1】:

    当你看到这样的警告时:

    Warning: React version not specified in eslint-plugin-react settings. See https://github.com/yannickcr/eslint-plugin-react#configuration .
    

    尝试在你的 eslint 配置文件中添加 React 版本设置,例如.eslintrc.js,如下所示:

    // .eslintrc.js
    {
      ...
      settings: {
        react: {
          version: 'detect',
        },
      },
    }
    

    【讨论】:

      【解决方案2】:
      module.exports = {
        env: {
          browser: true,
          es2021: true,
          jest: true,
          'react-native/react-native': true,
        },
        extends: [
          'eslint:recommended',
          'plugin:react/recommended',
          'plugin:react-hooks/recommended',
          'plugin:react-native/all',
        ],
        parserOptions: {
          ecmaFeatures: {
            jsx: true,
          },
          ecmaVersion: 12,
          sourceType: 'module',
        },
        plugins: ['react', 'react-hooks', 'react-native'],
        rules: {
          'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
          'global-require': 0,
          'operator-linebreak': [2, 'before'],
        },
      
        settings: {
          react: {
            version: "detect"
          }
        }
      };
      

      【讨论】:

      • 没有解释,比接受的答案晚了将近 1 年,还是一样
      猜你喜欢
      • 2021-08-14
      • 2019-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-03
      • 1970-01-01
      • 2015-02-23
      • 2012-11-11
      相关资源
      最近更新 更多