shaneMangudi / bcrypt-nodejs

Native implementation of bcrypt for NodeJS
Other
574 stars 69 forks source link

"Octal literal in strict mode" error in Webpack #82

Open larongbingo opened 6 years ago

larongbingo commented 6 years ago

Webpack shows me an error at ./node_modules/bcrypt-nodejs/bCrypt.js (293:40), anyone know how to fix this?

ERROR in ./node_modules/bcrypt-nodejs/bCrypt.js
Module parse failed: Octal literal in strict mode (293:40)
You may need an appropriate loader to handle this file type.
|       rounds = r1 + r2;
|       real_salt = salt.substring(off + 3, off + 25);
|       password = password + (minor >= 'a' ? "\000" : "");
|
|       var buf = new Buffer(password);
larongbingo commented 6 years ago
// webpack.config.js
module.exports = {
    entry: "./src/index.js",
    output: {
        path: path.resolve(__dirname, "build"),
        filename: "index.js"
    },
    module: {
        rules: [
            {
                test: /\.js?$/,
                loader: "babel-loader",
                options: {
                    presets: [
                        "env",
                        ["es2015", {"modules": false}]
                    ],
                    plugins: [
                        "transform-class-properties"
                    ]
                },
                exclude: [
                    path.resolve(__dirname, ".babelrc")
                ]
            },
            {
                test: /tar[\\\/].*\.js$/,
                loader: 'babel-loader!octal-number-loader'
            }
        ]
    },
    target: "node",
    cache: true,
    stats: "verbose", 
    devtool: "source-map",
    externals: ['pg', 'sqlite3', 'tedious', 'pg-hstore']
}