Quantcast
Channel: Node.js Tools for Visual Studio
Viewing all articles
Browse latest Browse all 4630

New Post: How do you reference Node JS projects within a solution?

$
0
0
Any MSBuild project can reference any other MSBuild project - this establishes a build dependency (if you build Project_2, it will automatically build Project_1 first). It does not establish a package dependency, though.

Ultimately, the behavior of require() is controlled by Node package resolution algorithm, as described here. NTVS doesn't really try to interfere with this in any way. So you can, for example, add the parent folder of both projects to NODE_PATH (there is a setting for environment variables in project properties), and then you should be able to use require - but 1) this will only work when you launch from VS, and you'll need to use .cmd scripts or similar to set the variable in the same manner when running your code manually, and 2) it breaks Node conventions.

A better option might be to arrange your projects on disk such that they're physically dependencies of each other - in other words, instead of copying Project_1 to Project_2's node_modules every time, just move it there on a permanent basis, and work on it directly from that folder, .njsproj file and all.

Viewing all articles
Browse latest Browse all 4630

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>