ClearC2 / react-excel-workbook

MIT License
109 stars 32 forks source link

Cannot resolve 'react-excel-workbook' #14

Open ElviraCB opened 6 years ago

ElviraCB commented 6 years ago

I've copy pasted the code on how to use the react excel workbook and added the code lines to my webpack config..

When I try to import the library I'm getting the following error:

Module not found: Error: Can't resolve 'react-excel-workbook' in '/usr/src/app/src'

I've installed the library withnpm install 'react-excel-workbook' command.

I can view the library in my node_modules folder.

I use this code to import the library: import Workbook from 'react-excel-workbook';

Webpack config:

// webpack.config.js
const webpack = require('webpack')
const path = require('path')
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const CopyWebpackPlugin = require('copy-webpack-plugin');

const config = {
  context: path.resolve(__dirname, 'src'),
  entry: './app.js',
  devServer: {
    contentBase: './dist'
  },
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js'
  },
  resolve: {
        // Add '.ts' and '.tsx' as resolvable extensions.
        extensions: [".ts", ".tsx", ".js", ".json"]
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        include: path.resolve(__dirname, 'src'),
        use: [{
          loader: 'babel-loader',
          options: {
            presets: [
              ['env', { modules: false }],
              "react"
            ]
          }
        }]
      },
      {
        test: /\.tsx?$/,
        loader: "awesome-typescript-loader"
      },
      {
        test: /\.css$/,
        use: ExtractTextPlugin.extract('css-loader')
      }
    ]
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify('development')
    }),
    new ExtractTextPlugin('bundle.css'),
    new CopyWebpackPlugin([
      { from: './cb_icons', to:'cb_icons' },
    ]),
  ],
  node: {fs: 'empty'},
  externals: [
    {'./cptable': 'var cptable'},
    {'./jszip': 'jszip'}
  ]
}

module.exports = config
rahulraj-120799 commented 4 years ago

Use yarn add react-excel-workbook