Vuejs: Cannot resolve module 'fs'

你。 提交于 2019-12-13 11:10:54

问题


I installed resource-bundle package:

npm install resource-bundle

But for building:

npm run build

gets error: 'cannot resolve module 'fs' '. what should i do?

webpack.base.conf.js:

'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')

function resolve (dir) {
   return path.join(__dirname, '..', dir)
}

module.exports = {
  entry: {
  app: './src/main.js'
  },
 output: {
 path: config.build.assetsRoot,
 filename: '[name].js',
 publicPath: process.env.NODE_ENV === 'production'
  ? config.build.assetsPublicPath
  : config.dev.assetsPublicPath
},
 resolve: {
 extensions: ['.js', '.vue', '.json'],
alias: {
  'vue$': 'vue/dist/vue.esm.js',
  '@': resolve('src')
}
},
 module: {
  ...
 }
}

node: {
fs: 'empty'
}

*added fs: 'empty' at the end.


回答1:


Try to add the following to your Webpack config:

node: {
   fs: "empty"
}


来源:https://stackoverflow.com/questions/48710170/vuejs-cannot-resolve-module-fs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!