找不到模块:无法解析“perf_hooks”ReactJS

Jor*_*nes 14 node.js typescript

我正在使用打字稿处理reactjs(17.0.1)(节点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'
Run Code Online (Sandbox Code Playgroud)

提前致谢

Tum*_*ire -1

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

npm i typescript @types/react @types/node
Run Code Online (Sandbox Code Playgroud)

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

  • 这对我不起作用。您还有其他解决方案吗? (4认同)