Error: Some of the library <YOUR LIBRARY> dependencies have not been built yet. Please build these libraries before: -testing
See original GitHub issueWe are getting this error:
Error: Some of the library "my-library" dependencies have not been built yet. Please build these libraries before: -testing
We have just upgraded to Angular 8 and are having an issue with our build.
We have two libraries generated by the Nrwl schematics (in Angular 7) within the same project. They are “my-library” and “testing”.
“testing” is a library that contains nothing but stubs for Angular components that exist in “my-library”. We build this library separate and place the build files in “my-library’s” distribution folder. This is so we can have the following pattern in our other applications.
import { myComponent } from "@abc/my-library" // for components
import { myComponentStub } from "@abc/my-library/testing" // for testing
Our dist folder structure looks like this.
dist >
@abc >
my-library >
testing > // testing directory
package.json
.....
We never had an issue with this error until we upgraded to angular 8 using Nx and tried to build.
The error shows up when we do ng build my-library
.
“Testing” is not a dependency used by “my-library” directly. But, the spec files within the library do.
They reference the stubs like so:
Import { myComponentStub } from @abc/testing
mapped through the jest.config.
jest.config.js
...
moduleNameMapper: {
"@abc/testing": "<rootDir>../../libs/testing/src/index.ts",
},
The issue might lie in these test imports. The build might be looking for “@abc/testing” at dist > @abc > testing
.
Prior versions of Angular “ng build” didn’t care about the spec file and their dependencies. Seeing this error is something only found in the Nx repo during a google search (angular-package.test.ts). I thought I would ask you.
Any idea how to resolve this?
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (1 by maintainers)
In my case, the @nrwl/angular:move command forgot to change the path set in libs/YOUR LIBRARY/ng-package.json. In any case someone (or my future me) stumbles over this issue again: Check the dist folder output!
After digging around through the code I was able to fix it! 👍
I found out that you can define the path for the “outputs” like this:
Without this Nx has defaulted to
dist/libs/shared/utils
- see: https://github.com/nrwl/nx/blob/master/packages/workspace/src/tasks-runner/utils.ts#L73