node-express app.get() marked as unresolved in webstorm

匿名 (未验证) 提交于 2019-12-03 02:56:01

问题:

If you follow JetBrains' Getting Started with Node.js in WebStorm instructions, node-express specific code is highlighted correctly. However if you create your own simple node-express project, e.g. using node-express' Guide, then express specific functions such as app.get() are underlined and marked with the following warning:

Unresolved function or method get() 

This happens even if you enable the following libraries under Settings\JavaScript\Libraries:

  • Node.js Globals
  • Node.js v0.10.31 Core Modules
  • express-DefinitelyTyped (which you need to download)

How can I configure WebStorm to resolve node-express functions such as app.get()?

回答1:

Instead of express definitelyTyped, use express types in your project:

npm install --save-dev @types/express 


回答2:

Enabling express-DefinitelyTyped typescript library for Express project does work for me - app.get() is successfully resolved. Adding typescript stubs is the only possible workaround, as WebStorm can't understand the way express is defined - see https://youtrack.jetbrains.com/issue/WEB-6667#comment=27-470393

If adding typescript stubs doesn't work for you, please try invalidating caches. If this doesn't help, I'd suggest contacting jetbrains support, providing a sample project



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!