Search code examples
angularangular-clinrwl-nxnrwl

Is it possible to change namespace name in @nrwl/nx?


Nrwl says ask here. Looks like I'm first!

I goofed. I created a project called Angular with the nx schematics. I want to rename the namespace, if that is possible, so that I can access my libraries like:

import {MyLibrary} from '@MyNamespace/my-library/';

Instead of:

import {MyLibrary} from '../../../../../../../..........';

I tried changing the project name in angular-cli.json and package.json, but I was pretty sure that wasn't the answer.

Also, nx will not work as a tag because it is already used elsewhere. I'm proposing nrwl-nx.

Edit: Scratch that. I don't have enough reputation to create a new tag. Kudos if you want to be the first!


Solution

  • Perhaps it is my question asking skills that need work, as the solution was very simple. Because I named my project Angular, my tsconfig.json file had this entry:

    "paths": {
        "@Angular/*": [
            "libs/*"
        ]
    }
    

    If you name your project folder one thing, but want to reference your library from another, this is where it is configured. I changed @Angular to @MyLibrary, and now my imports are import {SomeModule} from '@MyLibrary/some-module';