Javascript-why is an error reported when the node fs module is used for the code packaged with webpack?

Source: Internet
Author: User
{Code...} webpack configuration {code ...}
Var fs = require ("fs"); var path = require ('PATH'); the path module below will be okay, and fs will directly report an error. what is the situation?> Own@1.0.0 start C: \ Users \ gao \ Desktop \ github project learning \ backbone-resume-generator-master> node server. jsThu, 15 Sep 2016 13:01:33 GMT body-parser deprecated bodyParser: use inpidual json/urlencoded middlewares at server. js: 16: 9Thu, 15 Sep 2016 13:01:33 GMT body-parser deprecated undefined extended: provide extended option at node_modules \ body-parser \ index. js: 105: 29> Listening on port 3000. open up http://localhost:3000/ In your browser. hash: 95b9374fe25b22ba4242version: webpack 1.13.2Time: 978 ms Asset Size Chunks Chunk Namesbundle. js 439 kB 0, 1 [emitted] mainvendor. JSS 3.52 kB 1 [emitted] vendorchunk {0} bundle. js (main) 423 kB {1} [rendered] [0]. /public/js/app. JSS 1.55 kB {0} [built] [1]. /~ /Backbone. JavaScript 72.2 kB {0} [built] [2]./~ /Underscore. js 52.9 kB {0} [built] [3]./~ /Jquery/dist/jquery. JSS 264 kB {0} [built] [4]. /public/js/utils. JSS 1.02 kB {0} [built] [5]. /public/js/views ^ \. \/. * $289 bytes {0} [built] [6]. /public/js/views/form. JSS 3.96 kB {0} [built] [7]. /public/js/views/item. JSS 1.87 kB {0} [built] [8]. /public/js/models/items. js 322 bytes {0} [built] [9]. /public/js/views/list. JSS 2.24 kB {0} [built] [10]. /public/js/models/main. JSS 1.63 kB {0} [built] [11] ./~ /Backbone. localstorage/backbone. localStorage. JSS 7.45 kB {0} [built] [12]. /public/js/views/resume. JSS 1.68 kB {0} [built] [13]. /public/js/views/main. js 490 bytes {0} [built] [1 error] [14] (webpack )/~ /Node-libs-browser /~ /Path-browserify/index. js 6.18 kB {0} [built] [15] (webpack )/~ /Node-libs-browser /~ /Process/browser. js 5.3 kB {0} [built] chunk {1} vendor. js (vendor) 0 bytes [rendered] ERROR in. /public/js/views/main. jsModule not found: Error: Cannot resolve module 'Fs' in C: \ Users \ gao \ Desktop \ github project learning \ backbone-resume-generator-master \ public \ js \ views @. /public/js/views/main. js-24

Webpack configuration

var webpack = require('webpack');var path = require('path');module.exports = {    entry: './public/js/app.js',    output: {        path: path.join(__dirname, 'dist'),        filename: 'bundle.js',        publicPath: '/static/',        vendor: ['jquery', 'backbone', 'underscore']    },    plugins: [        new webpack.ProvidePlugin({            $: "jquery",            Backbone: "backbone",            _: "underscore"        }),        new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js')    ]

Reply content:
Var fs = require ("fs"); var path = require ('PATH'); the path module below will be okay, and fs will directly report an error. what is the situation?> Own@1.0.0 start C: \ Users \ gao \ Desktop \ github project learning \ backbone-resume-generator-master> node server. jsThu, 15 Sep 2016 13:01:33 GMT body-parser deprecated bodyParser: use inpidual json/urlencoded middlewares at server. js: 16: 9Thu, 15 Sep 2016 13:01:33 GMT body-parser deprecated undefined extended: provide extended option at node_modules \ body-parser \ index. js: 105: 29> Listening on port 3000. open up http://localhost:3000/ In your browser. hash: 95b9374fe25b22ba4242version: webpack 1.13.2Time: 978 ms Asset Size Chunks Chunk Namesbundle. js 439 kB 0, 1 [emitted] mainvendor. JSS 3.52 kB 1 [emitted] vendorchunk {0} bundle. js (main) 423 kB {1} [rendered] [0]. /public/js/app. JSS 1.55 kB {0} [built] [1]. /~ /Backbone. JavaScript 72.2 kB {0} [built] [2]./~ /Underscore. js 52.9 kB {0} [built] [3]./~ /Jquery/dist/jquery. JSS 264 kB {0} [built] [4]. /public/js/utils. JSS 1.02 kB {0} [built] [5]. /public/js/views ^ \. \/. * $289 bytes {0} [built] [6]. /public/js/views/form. JSS 3.96 kB {0} [built] [7]. /public/js/views/item. JSS 1.87 kB {0} [built] [8]. /public/js/models/items. js 322 bytes {0} [built] [9]. /public/js/views/list. JSS 2.24 kB {0} [built] [10]. /public/js/models/main. JSS 1.63 kB {0} [built] [11] ./~ /Backbone. localstorage/backbone. localStorage. JSS 7.45 kB {0} [built] [12]. /public/js/views/resume. JSS 1.68 kB {0} [built] [13]. /public/js/views/main. js 490 bytes {0} [built] [1 error] [14] (webpack )/~ /Node-libs-browser /~ /Path-browserify/index. js 6.18 kB {0} [built] [15] (webpack )/~ /Node-libs-browser /~ /Process/browser. js 5.3 kB {0} [built] chunk {1} vendor. js (vendor) 0 bytes [rendered] ERROR in. /public/js/views/main. jsModule not found: Error: Cannot resolve module 'Fs' in C: \ Users \ gao \ Desktop \ github project learning \ backbone-resume-generator-master \ public \ js \ views @. /public/js/views/main. js-24

Webpack configuration

var webpack = require('webpack');var path = require('path');module.exports = {    entry: './public/js/app.js',    output: {        path: path.join(__dirname, 'dist'),        filename: 'bundle.js',        publicPath: '/static/',        vendor: ['jquery', 'backbone', 'underscore']    },    plugins: [        new webpack.ProvidePlugin({            $: "jquery",            Backbone: "backbone",            _: "underscore"        }),        new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js')    ]

Let me know:

Why do front-end projects reference the fs module?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.