Nx: Target 'server' could not be found in project 'frontend'

Created on 17 Aug 2018  路  4Comments  路  Source: nrwl/nx

Hello, I am working on Angular 6 and trying to build application Server Side Rendering from several days.

I am continuously facing an error as below

"C:\JetBrains\PhpStorm 2018.2\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" run build:ssr --scripts-prepend-node-path=auto

> [email protected] build:ssr C:\Users\mchampaneria\phpstormprojects\angular_win\frontend
> npm run build:client-and-server-bundles && npm run webpack:server


> [email protected] build:client-and-server-bundles C:\Users\mchampaneria\phpstormprojects\angular_win\frontend
> ng run frontend:server

Target 'server' could not be found in project 'frontend'.
Error: Target 'server' could not be found in project 'frontend'.
    at Architect._getProjectTarget (C:\Users\mchampaneria\phpstormprojects\angular_win\frontend\node_modules\@angular-devkit\architect\src\architect.js:90:19)
    at Architect.getBuilderConfiguration (C:\Users\mchampaneria\phpstormprojects\angular_win\frontend\node_modules\@angular-devkit\architect\src\architect.js:97:29)
    at MergeMapSubscriber._loadWorkspaceAndArchitect.pipe.operators_1.concatMap [as project] (C:\Users\mchampaneria\phpstormprojects\angular_win\frontend\node_modules\@angular\cli\models\architect-command.js:72:55)
    at MergeMapSubscriber._tryNext (C:\Users\mchampaneria\phpstormprojects\angular_win\frontend\node_modules\rxjs\internal\operators\mergeMap.js:65:27)
    at MergeMapSubscriber._next (C:\Users\mchampaneria\phpstormprojects\angular_win\frontend\node_modules\rxjs\internal\operators\mergeMap.js:55:18)
    at MergeMapSubscriber.Subscriber.next (C:\Users\mchampaneria\phpstormprojects\angular_win\frontend\node_modules\rxjs\internal\Subscriber.js:64:18)
    at TapSubscriber._next (C:\Users\mchampaneria\phpstormprojects\angular_win\frontend\node_modules\rxjs\internal\operators\tap.js:62:26)
    at TapSubscriber.Subscriber.next (C:\Users\mchampaneria\phpstormprojects\angular_win\frontend\node_modules\rxjs\internal\Subscriber.js:64:18)
    at MergeMapSubscriber.notifyNext (C:\Users\mchampaneria\phpstormprojects\angular_win\frontend\node_modules\rxjs\internal\operators\mergeMap.js:84:26)
    at InnerSubscriber._next (C:\Users\mchampaneria\phpstormprojects\angular_win\frontend\node_modules\rxjs\internal\InnerSubscriber.js:25:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build:client-and-server-bundles: `ng run frontend:server`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build:client-and-server-bundles script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\mchampaneria\AppData\Roaming\npm-cache\_logs\2018-08-17T09_15_10_808Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build:ssr: `npm run build:client-and-server-bundles && npm run webpack:server`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build:ssr script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\mchampaneria\AppData\Roaming\npm-cache\_logs\2018-08-17T09_15_10_839Z-debug.log

Process finished with exit code 1

Since, my project name is 'frontend' and I am executing commands like below, after following full document describe on Angular Universal url

"build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server",
"serve:ssr": "node dist/server",
"build:client-and-server-bundles-old": "ng build --prod --extract-css && ng run frontend:server",
"webpack:server": "webpack --config webpack.server.config.js --progress --colors"

I was able to do this and successfully run server side rendering on Angular 5. But it is not working on Angular 6 and I have followed the changes done in Angular 6 too.

Is that any issue in Angular 6?

more info needed

All 4 comments

Can you please post your angular.json?

This issue is solved. Thanks

@github-mayur What was the fix for this? Even I am getting struggling with this issue. Thanks.

I am getting the same error
Project 'angular-universal-course:server' does not support the 'build' target
my angular.json code is

{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"angular-universal-course": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
"src/assets",
"src/favicon.ico"
],
"styles": [
"src/styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "angular-universal-course:build"
},
"configurations": {
"production": {
"browserTarget": "angular-universal-course:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "angular-universal-course:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": [],
"styles": [
"src/styles.scss"
],
"assets": [
"src/assets",
"src/favicon.ico"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"
/node_modules/"
]
}
},
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist/angular-universal-course-server",
"main": "src/main.server.ts",
"tsConfig": "src/tsconfig.server.json"
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"sourceMap": false,
"optimization": {
"scripts": false,
"styles": true
}
}
}
}
}
},
"angular-universal-course-e2e": {
"root": "",
"sourceRoot": "",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "angular-universal-course:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"e2e/tsconfig.e2e.json"
],
"exclude": [
"
/node_modules/"
]
}
}
}
}
},
"defaultProject": "angular-universal-course",
"schematics": {
"@schematics/angular:component": {
"prefix": "",
"styleext": "scss"
},
"@schematics/angular:directive": {
"prefix": ""
}
}
}

please suggest me where I am doing wrong....Thanks..

Was this page helpful?
0 / 5 - 0 ratings