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

nodemon does not restart with --watch src --exec 'yarn run build && yarn start' #1006

Closed
jd327 opened this issue Mar 28, 2017 · 7 comments
Closed

Comments

@jd327
Copy link

jd327 commented Mar 28, 2017

Why would this not work, what am I doing wrong?

nodemon --watch src --exec 'yarn run build && yarn start'

In src are all my files. It builds and starts just fine, but does not restart when anything is changed. Any ideas?

@remy
Copy link
Owner

remy commented Mar 28, 2017

Nope, no idea.

Can't really give you any better idea without seeing the output or a tree of src.

@remy remy changed the title nodemon does not restart nodemon does not restart with --watch src --exec 'yarn run build && yarn start' Mar 28, 2017
@jd327
Copy link
Author

jd327 commented Mar 28, 2017

Sorry, should've given more info.

The tree of src is this:

src/
  pages/
  public/
    css/
    js/
      index.js
  scripts/
  templates/
  404.hbs
  index.hbs

I've tried changing src/index.hbs and src/public/js/index.js but the server does not restart.

The output once I start nodemon the first time is this:

git:master ❯ nodemon --watch src --exec 'yarn run build && yarn start'
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: /path/to/repo/src/**/*
[nodemon] starting `yarn run build && yarn start`
...
<server starts correctly>

I also tried it with: nodemon -L ... and nodemon -e js,hbs ... and nodemon --watch src/**/*.hbs and still no luck.

@rvikmanis
Copy link

Should be src/ with a trailing slash.

@mcwienczek
Copy link

mcwienczek commented May 5, 2017

I have the same problem. Doesn't work whether with trailing slah or not.

Nodemon 1.11.0

Explicit file works:

nodemon --watch src/index.ts --exec 'node out/index.js'

Those don't:

nodemon --watch 'src' --exec 'node out/index.js'
nodemon --watch src --exec 'node out/index.js'
nodemon --watch 'src/' --exec 'node out/index.js'
nodemon --watch src/ --exec 'node out/index.js'
nodemon --watch 'src/**/*.ts' --exec 'node out/index.js'

UPDATE FIXED:

Sorry guys, after running nodemon in verbose it told me that by default it only watches *.js files.

After adding -e ts switch it all works again.

nodemon --watch src/ --exec 'node out/index.js' --verbose -e ts

@pjm4
Copy link

pjm4 commented Oct 14, 2017

The following is working for me as a very simple backup solution based on @mcwienczek answer:

"watch": "nodemon --watch . --exec backup -e *"

This watches all files and if any are changed runs a Windows batch file called backup.bat that only copies changed files to OneDrive.

This is the only command that worked for me to get npm to run an arbitrary script.

Including other files just for interest.

backup.bat

@echo off
xcopy /d /s /y /EXCLUDE:backup-exclude.txt . C:\Users\<user>\OneDrive\code-backup

backup-exclude.txt

.git
node_modules

@remy
Copy link
Owner

remy commented Dec 5, 2017

Closing as @philipjmurphy has a workaround for others to use (thank you!).

@remy remy closed this as completed Dec 5, 2017
@solish
Copy link

solish commented May 6, 2018

make sure your writhing your script are correct try this
"scripts": {
"start": "node server.js",
"server": "nodemon server.js"
},

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

No branches or pull requests

6 participants