Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modified 'start' script so changes to files in 'lib' trigger restart #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

OmarHussainX
Copy link

First of all, thank you for this example.

I'm assuming the intended behaviour for the npm start script is that changes to lib/index.js would show (after an automatic server restart) in the server running at http://127.0.0.1:1337/

That's the behaviour I expect, and I believe this is what was intended since the README states:

...replace Hello World with Hello {{YOUR_NAME_HERE}} while our server is running.
If you visit http://127.0.0.1:1337 you should see our server greeting you.

However the provided npm start script does not do this - changes to lib/index.js are detected, and trigger a server restart, but no transpilation is done, so dist/index.js is not updated and thus changes in lib do not appear in the server.

I've revised the npm start script so that: nodemon explicitly watches lib for changes, when a change occurs lib is transpiled to dist, and then the server is restarted.

@dkarski
Copy link

dkarski commented Feb 12, 2020

@OmarHussainX I think that you could use the proposal from this answer for the issue: #38 (comment)

{
  "scripts": {
    "build": "babel -d lib src",
    "watch": "nodemon --watch src --exec yarn start",
    "start": "yarn build && yarn serve",
    "serve": "node lib/index",
    "test": "echo \"No test specified\" && exit 0"
  },
}

And then you should update READ.md https://github.com/babel/example-node-server#example-node-server-w-babel

Watching file changes with nodemon could be move after Getting ready for production use section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants