node.js - Unresolved 功能或方法要求

标签 node.js typescript webstorm

我正在使用 WebStorm 构建 Node.js 应用程序。我正在使用 TypeScript。

当我使用“require”语句时,我收到此警告:

unresolved function or method require

它只发生在 TypeScript 文件中。在js文件中没有问题。代码有效,顺便说一句,这只是一个警告。

我发现了很多关于这个警告的问题,但它们都是关于 JavaScript 的,在我的项目中,js 文件对“require”语句没有问题,只有 ts 文件。

任何帮助将不胜感激!

最佳答案

I've found many questions about this warning but they all about JavaScript, and in my project js files have no problem with the "require" statement, just the ts files.

在 TypeScript 中,您需要声明您正在使用的所有内容,以防止出现拼写错误。

从 DefinitelyTyped 获取 node.d.ts:https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/node/node.d.ts

更多

https://basarat.gitbooks.io/typescript/content/docs/types/migrating.html

关于node.js - Unresolved 功能或方法要求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35543616/

相关文章:

javascript - vscode : rearrange code for js/ts files

typescript - 将引用传递给 setter

typescript - 在 Typescript 中,如何在声明之前使用函数?

intellij-idea - 如何在 PhpStorm 中预览方法内容

javascript - 为 nodejs 动态导入添加新扩展

javascript - CORS错误: Do I need some kind of server for my WebApp to subscribe to a Web Socket Feed?

javascript - 从没有 express 的形式转换 body 数据

javascript - 抛出新的类型错误 ('app.use() requires middleware functions' );

IDE 中的 Javascript 智能感知

ide - WebStorm 中 Hugo 的语法高亮显示