Node.js crypto gives webpack compile error -


i developing appilication using node.js, react, yarn , webpack , not experienced in these technologies.

i needed use encryption , tried use build-in crypto module. problem simple command: crypto = require('crypto'); in js file, webpack compilation fails following messages:

@ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/index.js  error in ./node_modules/parse-asn1/aesid.json module build failed: syntaxerror: unexpected token, expected ; (1:25)  > 1 | {"2.16.840.1.101.3.4.1.1": "aes-128-ecb",     |                          ^   2 | "2.16.840.1.101.3.4.1.2": "aes-128-cbc",   3 | "2.16.840.1.101.3.4.1.3": "aes-128-ofb",   4 | "2.16.840.1.101.3.4.1.4": "aes-128-cfb", 

i have tried use other encryption libraries node-simple-encryptor , sjcl same error!

i guess must webpack (version 3.5.2) problem, because when use same libraries in test javascript file , run nodejs interactive environment, runs ok.

can me?

my webpack.config.js file:

const path = require('path'); module.exports = {    entry: path.resolve(__dirname, 'src', 'index.js'),    output: {       path: path.resolve(__dirname, 'output'),       filename: 'bundle.js',       publicpath: '/'    },    resolve: {       extensions: ['.js', '.jsx']    },    module: {       rules: [          {              test: /\.js/,              use: {                 loader: 'babel-loader',                 options: { presets: ['react', 'es2015'] }              }          },          {             test: /\.scss/,             use: ['style-loader', 'css-loader', 'sass-loader']          }       ]    },    devserver: {      contentbase: './src',      publicpath: '/output',      historyapifallback: true,    },    devtool: 'source-map' //maps source files bundle.js debugging in browser  }; 

i think problem babel / webpack treating json file js try using first module.rules test key test: /\.(js)$/, instead of test: /\.js/,


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -