“Unresolved function or method” for require()

When you create or reopen a Node.js project in IntelliJ IDEA or WebStorm, you may see warnings such as "Unresolved function or method" for require() in module declarations that use require.

The application may still run, but productivity drops because the IDE does not fully recognize the Node.js project, for example, you cannot navigate to module usages.

In this case, enable the Coding assistance for Node.js option. On macOS, go to Preferences -> Languages & Frameworks -> Node.js and NPM.

nodejs and npm settings

Additionally, you can use Manage Scopes to define libraries used in specific files or directories. By default, the node_modules path under the current project is included.