[在JS中安装npm uuid后无法调用uuid函数

问题描述 投票:-2回答:1

使用电子在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不是函数

javascript node.js electron uuid
1个回答
0
投票

the documentation导入uuid的方式:

使用导入/导出语法:

import { v4 as uuid } from 'uuid';
uuid();

使用commonJs语法:

const uuid = require('uuid').v4;
uuid();
© www.soinside.com 2019 - 2024. All rights reserved.