错误:无法从“ C:\ Users \ 82103 \ Desktop \ SNS \ front”中找到模块“ babel-plugin-eslint-plugin-react-hook”

时间:2019-11-03 12:30:41

标签: webpack babel

webpack.config.js

const path = require('path');
const webpack = require('webpack');

module.exports = {
  mode: 'development',
  resolve: {
    modules: ['node_modules'],
    extensions: ['.jsx', '.js'],
  },

  entry: {
    app: './src',
  },
  module: {
    rules: [{
      test: /\.jsx?$/,
      exclude: /node_modules/,
      loader: 'babel-loader',
      options: {
        presets: ['@babel/preset-env', '@babel/preset-react'],
        plugins: [
          'react-hot-loader/babel',
          'eslint-plugin-react-hook',
        ],
      },
    }],

  },
  plugins: [
    new webpack.LoaderOptionsPlugin({ debug: true }),
  ],
  output: {
    filename: 'app.js',
    path: path.join(__dirname, 'bundle'),
  },
};

src / index.jsx

import React from 'react';
import ReactDOM from 'react-dom';
import { hot } from 'react-hot-loader/root';
import mainPage from './mainPage';

const Hot = hot(mainPage);

ReactDOM.render(<Hot />, document.querySelector('#root'));

和npm运行webpack-dev-server --hot

和..错误

./src/index.jsx中的

错误 模块构建失败(来自./node_modules/babel-loader/lib/index.js): 错误:无法从“ C:\ Users \ 82103 \ Desktop \ SNS \ front”找到模块“ babel-plugin-eslint-plugin-react-hook”     在Function.module.exports [同步时](C:\ Users \ 82103 \ Desktop \ SNS \ front \ node_modules \ resolve \ lib \ sync.js:74:15)

我不知道该怎么解决...帮助我..

npm'babel-plugin-eslint-plugin-react-hook'中没有模块

package.json

{
  "name": "snsproject",
  "version": "1.0.0",
  "description": "",
  "main": "src/index.js",
  "scripts": {
    "start": "webpack-dev-server --hot"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "antd": "^3.23.3",
    "axios": "^0.19.0",
    "babel-eslint": "^10.0.3",
    "google-map-react": "^1.1.5",
    "next": "^9.1.2",
    "react": "^16.9.0",
    "react-dom": "^16.9.0",
    "react-redux": "^7.1.1",
    "redux": "^4.0.4",
    "react-hot-loader": "^4.12.12",
    "styled-components": "^4.4.1"
  },
  "devDependencies": {
    "@babel/core": "^7.6.4",
    "@babel/preset-env": "^7.6.3",
    "@babel/preset-react": "^7.0.0",
    "babel-loader": "^8.0.6",
    "eslint": "^6.6.0",
    "eslint-config-airbnb": "^18.0.1",
    "eslint-plugin-import": "^2.18.2",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-react": "^7.14.3",
    "eslint-plugin-react-hooks": "^1.7.0",
    "webpack": "^4.39.3",
    "webpack-cli": "^3.3.7",
    "webpack-dev-server": "^3.8.0"
  }
}

.babelrc

{
  "presets": [
      "@babel/preset-env"
  ]
}

bundle / app.js

...
/***/ "./src/index.jsx":
/*!***********************!*\
  !*** ./src/index.jsx ***!
  \***********************/
/*! no static exports found */
/***/ (function(module, exports) {

eval("throw new Error(\"Module build failed (from ./node_modules/babel-loader/lib/index.js):\\nError: Cannot find module 'babel-plugin-eslint-plugin-react-hook' from 'C:\\\\Users\\\\82103\\\\Desktop\\\\SNS\\\\front'\\n    at Function.module.exports [as sync]...

/***/ })

/******/ });

0 个答案:

没有答案