使用电子在JS中安装npm uuid后,我无法调用uuid函数
这是安装终端时的消息,我不知道此安装是否正确
$ npm install uuid
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
+ [email protected]
updated 1 package and audited 120 packages in 1.746s
2 packages are looking for funding
run `npm fund` for details
found 1 low severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
这就是我调用函数的地方
ipcMain.on("appointment:create", (event, appointment) => {
appointment["id"] = uuid();
appointment["done"] = 0;
allAppointment.push(appointment);
CreateWindow.close();
console.log(allAppointment);
});
但是当我使用$ npm start运行程序时,它说TypeError:uuid不是函数
从the documentation导入uuid的方式:
import { v4 as uuid } from 'uuid';
uuid();
const uuid = require('uuid').v4;
uuid();