首页 > 解决方案 > 找不到模块:无法解析“perf_hooks”ReactJS

问题描述

我正在使用 typescript 处理 reactjs (17.0.1) (node v15.11.0) 并且收到此警告消息,知道如何解决吗?

./node_modules/typescript/lib/typescript.js
Critical dependency: the request of a dependency is an expression

./node_modules/typescript/lib/typescript.js
Critical dependency: the request of a dependency is an expression

./node_modules/typescript/lib/typescript.js
Module not found: Can't resolve 'perf_hooks' in '/Users/jorge/Documents/Development/Projects/React-Js/project/node_modules/typescript/lib'

提前致谢

标签: node.jstypescript

解决方案


在处理只有前端的 Next.JS 应用程序并在稍后添加 TS 时,我遇到了同样的错误。我相信这与 NPM TypeScript Node 包有关。我通过运行解决了它:

npm i typescript @types/react @types/node

安装所有 TypeScipt 依赖项(包括 Node)


推荐阅读