什么是 nodejs 的Deep Requires
在 nestjs 中 引入 uuid
import * as uuid from ‘uuid/v1’;
提示
(node:13212) DeprecationWarning: Deep requiring like const uuidv1 = require('uuid/v1');
is deprecated as of [email protected]. Please require the top-level module when using the Node.js CommonJS module or use ECMAScript Modules when bundling for
the browser. See https://github.com/uuidjs/uuid#deep-requires-now-deprecated for more information.
解决办法
import { v1 as uuidv } from ‘uuid’;
有个疑问 什么是 nodejs 的Deep Requires ?
2 回复
写的很清楚了,你之前的写法相当于 require uuid 模块下的 v1.js,这是不推荐的,应该直接 require 主模块 export 的属性