0

I am using angularjs2 with typescript in the client side and nodejs and express in the back-end, and every time i make changes to my client side files(.ts & .html) while running my node server on port 3000 i don't get the saved changes,so i have to run npm start for the ng-2 lite-server so that it like refreshes to get the changes, I am not sure whether i need a single module loader like SystemJS, which is the one i am using with ng2, or i need another systemjs required in my server so to get changes after saving.

In my server file i have

app.use(express.static(path.join(__dirname, 'client')));

that loads the static files, and which loads the index.html file that has the lines which i learn that they load application modules for ng2

 <script src="systemjs.config.js"></script>
<script>
  System.import('app').catch(function(err){ console.error(err); });
</script>

Since my server loads the index.html which contains the above code, im expecting nodejs and express to load the updated files accordingly, or is it because nodejs uses commonJS instead of system?

Is this the right way to do it or there is a better integration method for ng2 and nodejs?

What are the efficient options that are there in this aspect?

1 Answer 1

1

I'd suggest using pm2 to run your node server. The --watch flag will restart node (non-gracefully but quickly). If your Angular app is inside the node app folder then node will restart given just the flag, if it's outside that then you can pass a specified path to the --watch flag.

pm2 is a Production quality tool for Node, and works great locally too.

Details: http://pm2.keymetrics.io/docs/usage/watch-and-restart/
Example cmd: pm2 start index.js --watch

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.