Blacklite / Ncapsulate

NuGet and MSBuild wrappers around various Node based tools.
MIT License
29 stars 9 forks source link

How to install node_modules in a project's subfolder ? #13

Open blandine opened 9 years ago

blandine commented 9 years ago

Hi,

I would like to have the node_modules installed in one of the subfolder (where the package.json file is). I know that it's quite unusual, but is there a way to do that ?

Anyway, thanks for this useful tool!

david-driscoll commented 9 years ago

It might be possible, I can perhaps explore it in a week or two. Probably won't be a high priority change though.

peterrus commented 9 years ago

I moved mine a level up by using the following node.targets file

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <!-- Support for Incremental builds -->
  <!-- When package.json is changed, we'll install and update, then update lastrun -->
  <ItemGroup>
    <NpmJson Include="$(MSBuildProjectDirectory)\..\package.json" />
    <NpmLastRun Include="$(MSBuildProjectDirectory)\..\node_modules\npm.lastrun" />
  </ItemGroup>
  <Target Name="Npm" BeforeTargets="BeforeBuild" Inputs="@(NpmJson)" Outputs="@(NpmLastRun)">
    <NpmInstall />
    <NpmUpdate />
    <Delete Files="$(MSBuildProjectDirectory)\..\node_modules\npm.lastrun" />
    <WriteLinesToFile File="$(MSBuildProjectDirectory)\..\node_modules\npm.lastrun" Lines="" />
  </Target>
  <Target Name="NpmClean" BeforeTargets="BeforeClean">
    <Delete Files="$(MSBuildProjectDirectory)\..\node_modules\npm.lastrun" />
  </Target>
</Project>

You should be able to do something similar