node-uuid

Getting strange error using UUID npm module. What am I doing wrong?

天涯浪子 提交于 2020-05-15 06:00:14
问题 Getting "Error: Package exports for 'D:\test\node_modules\uuid' do not define a '.' subpath" all the time when I require it. OS - Windows 10 Pro Node version - v13.1.0 NPM version - 6.14.4 I created a project from scratch and run npm init -y to create initial package.json Then I installed uuid by running npm install uuid and created index.js with nothing but only const { v4: uuidv4 } = require('uuid'); uuidv4(); from their example But whenever I try to run this code node ./index.js I always

Jest: How to globally mock node-uuid (or any other imported module)

旧街凉风 提交于 2019-12-10 19:24:54
问题 Recently migrated from mocha to jest and I'm running into an issue. I have lots of warnings in my tests: [SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random() Now, adding the following line to each file fixes the issue, but only for that specific test file: jest.mock('node-uuid', () => ({ v4: jest.fn(() => 1) })); I'm hoping there's a way to mock node-uuid globally for all tests instead of individual files? I've done a bunch of searches and tried different techniques