5

I am using angualr7 with angular-cli and I am able to create new library with the following command.

E:\Coucou>ng generate library my-lib

By default it will add it under the project folder,but I need to generate the library under a sub folder of projects. Is there a way to do with angular-cli?

0

5 Answers 5

17

I had this same issue and solved it by scoping to the subfolder.

ng generate library @subfolder/my-lib
Sign up to request clarification or add additional context in comments.

4 Comments

This does work, however, one will be unable to build that target. ng build @subfolder/my-lib yields An unhandled exception occurred: Project '@subfolder/my-lib' does not support the 'build' target.
@JoseOrihuela, You have to update the path in angular.json
@FRM, thank you it works. Do you know if it possible to create under another subfolder. someting like /folder1/folder2/my-lib?
3

you can change the default project directory to the desired directory in the angular.json

"newProjectRoot": "your desired directory",

1 Comment

That isn't answered my question.By the way look at the comments ;)
0

Since this is still the primary Google result, and it took me way too much time to figure out:

You can just use the --project-root=<your directory> flag

Comments

-2

Just add the path. remember are relative to where you are

E:\Coucou>ng generate subFolder\library my-lib

or

E:\Coucou>ng generate C:\subFolder\library my-lib

1 Comment

I do not understand why I get downvote on that question. Nobody can tel me how to solve my problem but question is not accepted by the comunity!!
-2
ng generate library my-lib --directory=folder

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.