Reputation: 3105
Context: I'm using yarn workspace with a custom webpack/angular 5 conf for a while. I'm trying to use ng cli tool with angular 8. But a weird issue appears.
First, here is the error:
ERROR in ../node_modules/@project/messages/src/index.ts Module build failed (from ../node_modules/@ngtools/webpack/src/index.js): Error: /path/to/right/folder/node_modules/@project/messages/src/index.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (goo.gl/jB3GVv).
[Insert here terrible not humanly understandable stack trace]
I assume the problem is the symlink that yarn is creating. Here is my folder architecture.
.
├── libs
│ ├── messages
│ │ ├── dist
│ │ ├── LICENSE
│ ├── node_modules
│ │ ├── package.json
│ │ ├── src
│ │ └── tsconfig.json
│ └── physics
│ ├── jest.config.js
│ ├── LICENSE
│ ├── node_modules
│ ├── package.json
│ ├── src
│ └── tsconfig.json
├── LICENSE
├── game
│ ├── angular.json
│ ├── browserslist
│ ├── e2e
│ ├── karma.conf.js
│ ├── LICENSE
│ ├── node_modules
│ ├── package.json
│ ├── README.md
│ ├── src
│ ├── tsconfig.app.json
│ ├── tsconfig.json
│ ├── tsconfig.spec.json
│ ├── tslint.json
│ └── yarn.lock
├── node_modules
│ ├── @project
│ └── some other packages (mb like over 99999999, but nvm)
├── package.json
├── README.md
├── server
│ ├── LICENSE
│ ├── main.ts
│ ├── node_modules
│ ├── package.json
│ ├── src
│ └── tsconfig.json
└── yarn.lock
And also symlink mapping:
ls -la node_modules/@project
total 40
drwxrwxr-x 2 nek nek 4096 juin 24 23:24 .
drwxrwxr-x 912 nek nek 36864 juin 24 23:24 ..
lrwxrwxrwx 1 nek nek 14 juin 24 23:24 client -> ../../game
lrwxrwxrwx 1 nek nek 19 juin 24 23:24 messages -> ../../libs/messages
lrwxrwxrwx 1 nek nek 18 juin 24 23:24 physics -> ../../libs/physics
lrwxrwxrwx 1 nek nek 22 juin 24 23:24 server -> ../../server
Nothing looks so wrong. But at build time it fails. I can't understand why. But check out this output of ng --version
:
$ ng --version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 8.0.4
Node: 10.16.0
OS: linux x64
Angular: <error>
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
---------------------------------------------------------
@angular-devkit/architect <error>
@angular-devkit/build-angular <error>
@angular-devkit/core <error>
@angular-devkit/schematics <error>
@schematics/angular <error>
@schematics/update <error>
rxjs <error>
typescript <error>
It looks somehow like this issue: https://github.com/angular/angular-cli/issues/3864#issuecomment-303168778 but I don't have the same problem (considering the location of node_modules is accurate in my case).
Thanks for any help!
Upvotes: 2
Views: 969
Reputation: 3105
I started a new project with npm/lerna (should work just like yarn workspaces). And had same issue. But solved it.
The problem was the configuration of TypeScript (in tsconfig.json file). I set the path
configuration of my tsconfig:
"compilerOptions": {
"paths": {
"@project/physics": ["../libs/physics"]
}
}
Working like a charm.
Upvotes: 2