I'm studying MEAN 2.0 . I need to do "ng build" before running "node server.js".
I would like to ask if do I need to do (ng build) everytime I changed something in my angular side? Because when I'm using only angular-cli, when I changed something and my server is still running. It will show the changes. I tried to change something but when I re-run my node server nothing happens.
Yes you need to do ng build before running node server.js.
ng serve :- serves on a server, node server.js :- doesnt serve on the same port, it runs on the port you define in your server.js, it reads from the build folder, which will need updated fies.
Live reload wont work :(
You can 1. write tasks for it 2. write script in package.json which does ng build && node server.js
If you arranged your folder structure to be:
|_server |_ server.js |_ public (angular-cli project) |_ dist |_ src |_ package.json (client) |_package.json(server)
angular-cli
package.json
, concurrently
using npm: npm install concurrently --save-dev
server package.json
: "scripts": { "client":"cd public && ng build", "server":"ndoe ./server/server", "start":"concurrently --kill-others \\"npm run client\\" \\"npm run server\\"" }
npm run start
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.