Error / Issue
在学习 React 的时候,发现别人教的视频引用 uuid 的时候是通过:
import uuidv4 from 'uuid/v4
但是在本地编译的时候出错,提示:
Module not found: Can't resolve 'uuid/v4'
Root Cause
This error happens because of the file structure in node_modules/uuid, if you look there is no longer a uuidv4 to import and instead they export a v4. You could change all the places where the developers wrote uuidv4 to v4 but using the { this as that } syntax you don’t have to rewrite a bunch of code.
npm install uuid
const {v4:uuidv4} = require('uuid');
1 | setTodo((prevTodo) => { |