laravel 找不到模块:错误:无法解析“fs”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40950176/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Module not found: Error: Can't resolve 'fs'
提问by abu abu
I working on a Laravel 5.3 project. I am getting below errors when I am running gulp
command in CMD.
我在 Laravel 5.3 项目上工作。gulp
在 CMD 中运行命令时出现以下错误。
Could anyone say how can I get a error less result ?
谁能说我怎么能得到一个错误更少的结果?
gulpfile.js
gulpfile.js
var elixir = require('laravel-elixir');
require('laravel-elixir-vue');
elixir(function(mix) {
mix.sass('app.scss');
});
elixir(function(mix) {
mix.webpack('app.js');
});
elixir(function(mix) {
mix.version(['css/app.css', 'js/app.js']);
});
package.json
包.json
{
"private": true,
"scripts": {
"prod": "gulp --production",
"dev": "gulp watch"
},
"devDependencies": {
"babel-core": "^6.18.2",
"babel-loader": "^6.2.7",
"babel-plugin-add-module-exports": "^0.2.1",
"bootstrap": "^4.0.0-alpha.3",
"bootstrap-sass": "^3.3.7",
"buble": "^0.14.2",
"gulp": "^3.9.1",
"jquery": "^3.1.0",
"laravel-elixir": "^6.0.0-9",
"laravel-elixir-browserify-official": "^0.1.3",
"laravel-elixir-vue": "^0.1.4",
"laravel-elixir-vue-2": "^0.2.0",
"laravel-elixir-webpack-official": "^1.0.2",
"lodash": "^4.14.0",
"vue": "^1.0.26",
"vue-resource": "^0.9.3"
},
"dependencies": {
"admin-lte": "^2.3.7",
"node-sass": "^3.13.0"
}
}
回答by TimothePearce
If your using Laravel 5.5 or above, simply add:
如果您使用 Laravel 5.5 或更高版本,只需添加:
mix.webpackConfig({ node: { fs: 'empty' }})
to your webpack.mix.js
file.
到您的webpack.mix.js
文件。
回答by Antonio Carlos Ribeiro
Try adding
尝试添加
Elixir.webpack.mergeConfig({
node: {
fs: 'empty',
}
});
To your gulpfile.js. Looks like this is a known webpack problem. Here's your file edited:
到你的gulpfile.js。看起来这是一个已知的 webpack 问题。这是您编辑的文件:
var elixir = require('laravel-elixir');
require('laravel-elixir-vue');
Elixir.webpack.mergeConfig({
node: {
fs: 'empty',
}
});
elixir(function(mix) {
mix.sass('app.scss');
});
elixir(function(mix) {
mix.webpack('app.js');
});
elixir(function(mix) {
mix.version(['css/app.css', 'js/app.js']);
});