xlsx-style使用中常见问题及解决办法

问题1. Can‘t resolve ‘./cptable‘ in ‘xxx\node_modules_xlsx
在vue.config.js中引入以下代码

configureWebpack: {
    externals: {
      './cptable': 'var cptable'
    },
  },

问题2. Can’t resolve ‘fs’
在vue.config.js中引入以下代码

module.exports = defineConfig({
  transpileDependencies: true,
  configureWebpack: {
 
    externals: {
      './cptable': 'var cptable'
    },
    resolve: {
      fallback: {
        fs: false
      }
    },
  }
})

问题3:Can't resolve 'crypto'in D: code-a\LPA2 admin node modules (xlsx-style)
在vue.config.js中引入以下代码

module.exports = defineConfig({
  transpileDependencies: true,
  configureWebpack: {
 
    externals: {
      './cptable': 'var cptable'
    },
    resolve: {
      fallback: {
        fs: false,
        crypto: false,
      }
    },
  }
})

问题4. jszip not a constructor
通过命令安装Webpack 插件
npm i node-polyfill-webpack-plugin -D
在vue.config.js中引入以下代码


const NodePolyfillPlugin = require("node-polyfill-webpack-plugin")
 
module.exports = defineConfig({
  configureWebpack: {
    plugins: [
        new NodePolyfillPlugin()
      ]
    }
})

处理完后vue.config.js整体代码如下

const { defineConfig } = require("@vue/cli-service");
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin")

module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave: false,
  devServer: {
    port: 8080, 
    host: '0.0.0.0',
    client: {
      webSocketURL: 'ws://0.0.0.0:8080/ws',
    },
    headers: {
      'Access-Control-Allow-Origin': '*',
    },
    proxy: {
      '/':{
        ws: false,
        target:"http://127.0.0.1:3000",
        pathRewrite:{
          "^/":"/"
        }
      }
    }
  },
  configureWebpack: {
      plugins: [
          new NodePolyfillPlugin()
        ],
    externals: {
      './cptable': 'var cptable'
    },
    resolve: {
      fallback: {
        fs: false,
        crypto: false,
      }
    },
  }

});

相关推荐

  1. xlsx-style使用常见问题解决办法

    2023-12-21 18:34:03       42 阅读
  2. Redis使用常见问题解决方案

    2023-12-21 18:34:03       42 阅读
  3. docker实际生产遇到的问题解决办法

    2023-12-21 18:34:03       37 阅读
  4. 常见的HTTP接口超时问题出现原因解决办法

    2023-12-21 18:34:03       40 阅读
  5. MabatisString类型传参常见问题解决办法

    2023-12-21 18:34:03       31 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-21 18:34:03       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-21 18:34:03       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-21 18:34:03       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-21 18:34:03       18 阅读

热门阅读

  1. 在服务器上使用“nohup”命令运行Jupyter Notebook

    2023-12-21 18:34:03       42 阅读
  2. Android ViewModel的简单应用

    2023-12-21 18:34:03       29 阅读
  3. 力扣56. 合并区间

    2023-12-21 18:34:03       30 阅读
  4. liunx安装git

    2023-12-21 18:34:03       44 阅读
  5. JNI学习(一)

    2023-12-21 18:34:03       37 阅读
  6. 【SpringBoot】知识点总结

    2023-12-21 18:34:03       42 阅读
  7. css 2D转换

    2023-12-21 18:34:03       29 阅读