我的主代码。我在node_modules文件夹中有"require('node-rsa')“。可以从这段代码创建一个文件吗?
a.js
var testFunct = function test(message) {
const NodeRSA = require('node-rsa');
const key = new NodeRSA();
var k = key.generateKeyPair();
var p = k.exportKey('pkcs1');
return p};
console.log(testFunct())
package.json
{
"name": "pol",
"version": "1.0.0",
"description": "",
"main": "a.js",
"dependencies": {
"node-rsa": "^1.1.1",
"build": "webpack a.js b.js"
},
"devDependencies": {
"webpack": "^5.58.2"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
webpack.config.js
module.exports = {
entry: ['a.js'],
output: {
path: './build',
filename: 'bundle.js'
}
}
发布于 2021-10-14 04:54:57
将以下条目添加到package.json的scripts
部分:
"build": "webpack"
这将在您运行构建操作时触发webpack。
https://stackoverflow.com/questions/69570790
复制相似问题