Thursday, 1 June 2017

Angular cli require package from local node modules instead of the root

I created a new angular-cli project. I have a TestModule that I require in my app.module.

The TestModule is in the test folder. The test folder has it's own package.json with a different version of some npm package.

This is my tree:

  --node_modules
     -npmPackage@2.0.0
    --src
        --app
          -app.module.ts
        --test
         -node_modules
           -npmPackage@1.0.0
         -package.json
         -test.module.ts

Now when I require npmPackage in my test module like this:

import {npmPackage} from 'npmPackage';

I am getting the version from the root directory (i.e., 2.0.0). How can I force it to take the version from the first node_modules without doing something like this:

import {npmPackage} from './node_modules/npmPackage';



via ng2user

No comments:

Post a Comment