Open NasinLin opened 5 years ago
sounds like you're holding webpack wrong. How can I reproduce the issue you're observing, as it looks like a failure from webpack, and it's not clear how node-nanomsg is related?
This is my webpack.config file
const path = require('path');
module.exports = {
target: 'node',
mode: 'production',
entry: './index.js',
output: {
path: path.resolve(__dirname, ''),
filename: 'main.js'
},
module: {
rules: [{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}]
}
};
This is my index file
const commandLineArgs = require('command-line-args');
const fs = require('fs');
const nano = require('nanomsg');
const server = nano.socket('rep');
const optionDefinitions = [{
name: 'config',
alias: 'c',
type: String
}];
const options = commandLineArgs(optionDefinitions);
if (!options.config) {
console.log('no options');
process.exit(0);
}
const config = JSON.parse(fs.readFileSync(options.config).toString());
console.log(JSON.stringify(config));
When I remove this line "require('nanomsg')" , It's working is fine
Hi, I'm using nanomsg lib to run nodejs is success and then I want to use webpack to build nodejs is ok , but I can't run js after build.
I get error message .
How can I resolve the error?