用mpvue开发小程序,页面突然报错:

 

This dependency was not found:* fs in ./node_modules/destroy/index.js, ./node_modules/etag/index.js

重新安装npm install --save fs   也不行,最后网上找到解决办法:

  1. 找到build文件下的 webpack.base.conf.js
  2. 在如下图位置:

上述代码:

node: {
    // prevent webpack from injecting useless setImmediate polyfill because Vue
    // source contains it (although only uses it if it‘s native).
    setImmediate: false,
    // prevent webpack from injecting mocks to Node native modules
    // that does not make sense for the client
    dgram: "empty",
    fs: "empty",
    net: "empty",
    tls: "empty",
    child_process: "empty"
  },

 重启项目,就成功了!

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐