How to check is project is NPM type

Answered

Hello,

 

Are there IntelliJ APIs to identify if the project is NPM type? 

 

For example, for Maven I use

MavenProjectsManager.getInstance(project).getRootProjects

And for Gradle I use

GradleSettings.getInstance(project).getLinkedProjectsSettings

 

 

Is there something similar for npm?

 

Thank you!

 

Best regards,

Alex.

0
2 comments
Official comment

NPM features don't need to configure project model, it can be available in any project. Usually presence of `package.json` is a sign to enable most features.

To get list of all package.json files in a project, use

PackageJsonFileManager.getInstance(project).getValidPackageJsonFiles()

and to find an ancestor package.json for a file, use

PackageJsonUtil.findUpPackageJson(file)

 

Thank you, Sergey!!! 👍

0

Please sign in to leave a comment.