Closed niklas-wortmann closed 5 years ago
@JWO719, thanks for raising this issue - can you clarify a little?
Is the workspace already an Nx workspace? Or are you trying to add Nx schematics to a workspace generated by Angular CLI?
If you can provide a link to a repo which reproduces the exception or otherwise provide steps to reproduce, that would be super useful, thanks!
Alternatively, just providing the angular.json
file may give an idea what's going wrong.
Thanks for supporting with this one!
So for now it is a basic angular cli workspace project. I want to use the migration schematic to make it an Nx workspace.
Unfortunately I can't share a link to a repo but here is the angular.json file:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "src",
"cli": {
"packageManager": "npm"
},
"projects": {
"client": {
"root": "client",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/client",
"index": "src/client/index.html",
"main": "src/client/main.ts",
"tsConfig": "src/client/../tsconfig.app.json",
"polyfills": "src/client/../polyfills.ts",
"stylePreprocessorOptions": {
"includePaths": [
"src/shared/styles",
"src/client/styles"
]
},
"assets": [
{
"glob": "**/*",
"input": "src/client/assets",
"output": "/assets"
},
{
"glob": "**/*",
"input": "src/shared/assets",
"output": "/assets"
}
],
"styles": [
"src/shared/styles/global.scss",
"src/client/styles/client.scss"
],
"scripts": []
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"fileReplacements": [
{
"replace": "src/client/environments/environment.ts",
"with": "src/client/environments/environment.prod.ts"
}
]
},
"dev": {
"fileReplacements": [
{
"replace": "src/client/environments/environment.ts",
"with": "src/client/environments/environment.dev.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "client:build",
"port": 3000,
"host": "localhost"
},
"configurations": {
"production": {
"browserTarget": "client:build:production"
},
"dev": {
"browserTarget": "client:build:dev"
},
"e2e": {
"browserTarget": "client:build:e2e"
},
"hmr": {
"hmr": true,
"hmrWarning": false,
"browserTarget": "client:build:hmr"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "client:build"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json"
],
"exclude": [
"**/node_modules/**/*"
]
}
},
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js"
}
}
}
},
"admin": {
"root": "admin",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"baseHref": "/admin/",
"deployUrl": "/admin/",
"outputPath": "dist/admin",
"index": "src/admin/index.html",
"main": "src/admin/main.ts",
"tsConfig": "src/admin/../tsconfig.app.json",
"polyfills": "src/admin/../polyfills.ts",
"stylePreprocessorOptions": {
"includePaths": [
"src/shared/styles",
"src/admin/styles"
]
},
"assets": [
{
"glob": "**/*",
"input": "src/admin/assets",
"output": "/assets"
},
{
"glob": "**/*",
"input": "src/shared/assets",
"output": "/assets"
}
],
"styles": [
"src/shared/styles/global.scss",
"src/admin/styles/admin.scss"
],
"scripts": []
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"fileReplacements": [
{
"replace": "src/admin/environments/environment.ts",
"with": "src/admin/environments/environment.prod.ts"
}
]
},
"dev": {
"fileReplacements": [
{
"replace": "src/admin/environments/environment.ts",
"with": "src/admin/environments/environment.dev.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "admin:build",
"port": 3001,
"host": "localhost"
},
"configurations": {
"production": {
"browserTarget": "admin:build:production"
},
"dev": {
"browserTarget": "admin:build:dev"
},
"e2e": {
"browserTarget": "admin:build:e2e"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "admin:build"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json"
],
"exclude": [
"**/node_modules/**/*"
]
}
}
}
}
},
"defaultProject": "client",
"schematics": {
"@schematics/angular:component": {
"prefix": "ems",
"styleext": "scss"
},
"@schematics/angular:directive": {
"prefix": "ems"
}
}
}
Thanks for providing the angular.json
- a few things jump out as being unusual :
root
to be contained within sourceRoot
(you've given newProjectRoot
as src
, so I'd expect root
to be src/{admin/client}
and sourceRoot
to be src/{admin/client}/src
in each case)test
target for either project?index.html
files seem to be located oddly? (I'd expect them to be at src/{admin/client}/src/index.html
)It could be that something about your configuration is so unusual that the schematic can't work with your workspace.
Having said that, I've set up a similar project configuration here which also raises an error when ng add @nrwl/workspace
is run... (a different error though)
Sorry for the late feedback. The issue above was caused by the missing test target.
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
I'm having an angular cli workspaces project where I have two separate projects. Running
ng add @nrwl/workspace
just throws the following exception.The project is running with Angular@8.2.4. Additional it's running on a Mac with node@10.11.0 & npm@6.10.3.
Due to the lack of additional information, besides this exception, I'm kinda lost how to proceed here. I could imagine, that there is a slightly broken configuration in my project, but I don't a single idea of what to look for.
Many thanks for the help!