Webpack: Cannot resolve modules 'fs' 'net' 'tls' when using Couchbase

Created on 2 Jun 2016  路  1Comment  路  Source: webpack/webpack

Good afternoon,

We are trying to use the node module for Couchbase. When just using var couchbase = require('couchbase') we ran into this while building:

my webpack.config looks like:

var webpack = require('webpack');
var path = require('path');

module.exports = {
    context: path.join(__dirname, "src"),
    devtool: debug ? "inline-sourcemap" : null,
    entry: "./js/client.js",
    module: {
        loaders: [
                {
                test: /\.json$/,
                loader: 'json'
            },
            {
                test: /\.jsx?$/,
                exclude: /(node_modules|bower_components)/,
                loader: 'babel-loader',
                query: {
                    presets: ['react', 'es2015', 'stage-0'],
                    plugins: ['react-html-attrs', 'transform-class-properties', 'transform-decorators-legacy'],
                }
            }
        ]
    },
    node: {
      fs: 'empty',
      net: 'empty',
      tls: 'empty',
      dns: 'empty'
},
    output: {
        path: __dirname + "/src/",
        filename: "client.min.js"
    },
    plugins: debug ? [
        new webpack.IgnorePlugin(/^(buffertools)$/)
    ] : [
        new webpack.IgnorePlugin(/^(buffertools)$/),
        new webpack.optimize.DedupePlugin(),
        new webpack.optimize.OccurenceOrderPlugin(),
        new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
    ],
    devServer: {
        historyApiFallback: true
    }
};

I recently added the node: {} element and now I'm getting:

WARNING in ./~/bindings/bindings.js
Critical dependencies:
76:22-40 the request of a dependency is an expression
76:43-53 the request of a dependency is an expression
@ ./~/bindings/bindings.js 76:22-40 76:43-53
webpack: bundle is now VALID.

In chrome console i am seeing error:

Uncaught ReferenceError: require is not defined

We are on Node 6.2.0, please let me know if you need anymore details

james

question

Most helpful comment

The official Couchbase Node.js Client Library.

It's a library for node.js not for in-browser usage.

>All comments

The official Couchbase Node.js Client Library.

It's a library for node.js not for in-browser usage.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abergs picture abergs  路  3Comments

yannispanousis picture yannispanousis  路  3Comments

dubrowgn picture dubrowgn  路  3Comments

haohcraft picture haohcraft  路  3Comments

adjavaherian picture adjavaherian  路  3Comments