DEV Community

Cover image for Angular-CLI and NW.js for development

Angular-CLI and NW.js for development

The Jared Wilcurt on February 24, 2019

This will walk you through setting up NW.js and Angular-CLI from scratch. "Why not just do all this for me and just give me a boilerplate" Do y...
Collapse
 
redmission84 profile image
Andy

This is the best tutorial I've seen for integrating Angular and NW JS (learning the latter now) and it's helpful to be able to launch them both with a simple "npm start". I also love how you can simply specify the window options in package.json and it just works. Thanks for this tutorial!

Collapse
 
fprijate profile image
Franček Prijatelj

The problem with using
"main": "localhost:8964",
is that you can't debug bg code,because there isn't any
(only front end code from "remote" page).
Try to inspect process or global variable in devtools.

Collapse
 
fprijate profile image
Franček Prijatelj

Sorry

It works with "node-remote" set.

Collapse
 
vinayd profile image
Vinaykumar Devarkond

Thanks for the tutorial. But when I used window.nw, i am getting nw as undefined. Please help.

Collapse
 
thejaredwilcurt profile image
The Jared Wilcurt

You can see examples here: github.com/nwutils/nw-angular-cli-...

Either you aren't running your code in NW.js or you are running it from a Node.js context (in which case you could use nw directly, or global.nw).

Collapse
 
hnguyen48206 profile image
hnguyen48206

Thank you sir for this great tutorial. I'm trying to use my pre-existing angular project (with ngx-admin) in an nw.js app. Following your instruction, I've been able to run the angular local server and nw app just fine for development but the problem is that in nw.js context, the UI cannot get pass the index.html file and got stuck there while this is not the case when running the web in browser.

This is my package.json.

{
"main": "localhost:8964",
"node-remote": "localhost:8964",
"window": {
"width": 960,
"height": 600,
"min_width": 700,
"min_height": 500
},
"name": "ngx-admin",
"version": "7.0.0",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+github.com/akveo/ngx-admin.git"
},
"bugs": {
"url": "github.com/akveo/ngx-admin/issues"
},
"scripts": {
"ng": "ng",
"conventional-changelog": "conventional-changelog",
"start": "concurrently \"npm run start:web\" \"wait-on localhost:8964 && nw .\"",
"start:web": "ng serve --port=8964",
"build": "ng build",
"build:prod": "npm run build -- --prod --aot",
"test": "ng test",
"test:coverage": "rimraf coverage && npm run test -- --code-coverage",
"lint": "ng lint",
"lint:fix": "ng lint ngx-admin-demo --fix",
"lint:styles": "stylelint ./src/*/.scss",
"lint:ci": "npm run lint && npm run lint:styles",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "ng e2e",
"docs": "compodoc -p src/tsconfig.app.json -d docs",
"docs:serve": "compodoc -p src/tsconfig.app.json -d docs -s",
"prepush": "npm run lint:ci",
"release:changelog": "npm run conventional-changelog -- -p angular -i CHANGELOG.md -s",
"postinstall": "ngcc --properties es2015 es5 browser module main --first-only --create-ivy-entry-points --tsconfig \"./src/tsconfig.app.json\""
},
"dependencies": {
"@akveo/ng2-completer": "^9.0.1",
"@angular/animations": "^11.0.9",
"@angular/cdk": "11.0.4",
"@angular/common": "^11.0.9",
"@angular/compiler": "^11.0.9",
"@angular/core": "^11.0.9",
"@angular/forms": "^11.0.9",
"@angular/google-maps": "^11.0.4",
"@angular/material": "^11.0.4",
"@angular/material-moment-adapter": "^11.2.13",
"@angular/platform-browser": "^11.0.9",
"@angular/platform-browser-dynamic": "^11.0.9",
"@angular/router": "^11.0.9",
"@asymmetrik/ngx-leaflet": "3.0.1",
"@nebular/auth": "7.0.0",
"@nebular/eva-icons": "7.0.0",
"@nebular/security": "7.0.0",
"@nebular/theme": "7.0.0",
"@swimlane/ngx-charts": "^14.0.0",
"@swimlane/ngx-datatable": "^20.0.0",
"angular2-chartjs": "0.4.1",
"axiom-ngx-tree": "^1.0.1",
"bootstrap": "4.3.1",
"chart.js": "2.7.1",
"ckeditor": "4.7.3",
"classlist.js": "1.1.20150312",
"core-js": "2.5.1",
"echarts": "^4.0.2",
"eva-icons": "^1.1.3",
"intl": "1.2.5",
"ionicons": "2.0.1",
"js-sha256": "^0.9.0",
"leaflet": "1.2.0",
"moment": "^2.29.1",
"nebular-icons": "1.1.0",
"ng-otp-input": "^1.8.1",
"ng2-ckeditor": "^1.2.9",
"ng2-smart-table": "^1.6.0",
"ngx-echarts": "^4.2.2",
"node-sass": "^4.12.0",
"normalize.css": "6.0.0",
"pace-js": "1.0.2",
"roboto-fontface": "0.8.0",
"rxjs": "6.6.2",
"rxjs-compat": "6.3.0",
"socicon": "3.0.5",
"style-loader": "^1.1.3",
"tinymce": "4.5.7",
"tslib": "^2.0.0",
"typeface-exo": "0.0.22",
"wait-on": "^6.0.1",
"web-animations-js": "^2.3.2",
"zone.js": "~0.10.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1100.7",
"@angular/cli": "^11.0.7",
"@angular/compiler-cli": "^11.0.9",
"@angular/language-service": "11.0.9",
"@compodoc/compodoc": "1.0.1",
"@fortawesome/fontawesome-free": "^5.2.0",
"@types/d3-color": "1.0.5",
"@types/googlemaps": "^3.39.3",
"@types/jasmine": "^3.3.0",
"@types/jasminewd2": "2.0.3",
"@types/leaflet": "1.2.3",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"concurrently": "^7.0.0",
"conventional-changelog-cli": "1.3.4",
"husky": "0.13.3",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.1.1",
"karma-chrome-launcher": "~3.1.0",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"npm-run-all": "4.0.2",
"nw": "^0.18.7",
"protractor": "~7.0.0",
"rimraf": "2.6.1",
"stylelint": "7.13.0",
"ts-node": "3.2.2",
"tslint": "~6.1.0",
"tslint-language-service": "^0.9.9",
"typescript": "4.0.5"
}
}

Collapse
 
gepid profile image
Jan Roman Cisowski

and how do you use it to work with nw-builder, or something else?

Collapse
 
thejaredwilcurt profile image
The Jared Wilcurt

github.com/nwutils/nw-angular-cli-...

All set up! npm install && npm run build

Collapse
 
kriefsacha profile image
kriefsacha

Hi , how do you get the release when you finished your angular nw.js application ? Thanks for everything !

Collapse
 
thejaredwilcurt profile image
The Jared Wilcurt