我正在用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'
提前感谢
据我所知,这仍然是一个悬而未决的问题:https://github.com/microsoft/TypeScript/issues/39436
当我从typescript导入任何东西时,我会收到完全相同的3个警告-例如:
import { transpile } from 'typescript';
结果在:
编译时带有警告。
/node_modules/typescript/lib/typescript.js关键依赖项:依赖项的请求是一个表达式
/node_modules/typescript/lib/typescript.js关键依赖项:依赖项的请求是一个表达式
/node_modules/typescript/lib/typescript.js找不到模块:无法解析"C:\me\myName\GitHub\projectFolder\node_modules\typescript\lib"中的"perf_hooks">
我在编辑JavaScript代码并导入TypeScript依赖项时遇到了这个错误,即使我的项目支持TypeScript。
检查您的javascript文件是否有任何typescript依赖项。
我在处理一个只有前端的Next.JS应用程序时遇到了同样的错误,后来添加了TS。我相信这与NPM TypeScript Node包有关。我通过运行解决了这个问题
npm i typescript @types/react @types/node
安装所有TypeScipt依赖项(包括节点(
检查您的节点版本是否是node -v
的最新版本如果不是,您可以在https://nodejs.org/en/download/
下载并安装后,再次使用node -v
验证最新版本是否为默认版本。如果您无法更改节点版本并安装了nvm(节点版本管理器(,则可以选择nvm alias default xx.xx.x
(其中xx.xx.x是您希望用作默认的节点版本(。