@remy has edited this title - currently an outstanding issue
coffee script is compiling to js when the .coffee file changes but nodemon appears to be missing the change.
I'm getting started with node.js and using coffeescript as my default language. All is fine. So I start with some js in a coffee file:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Earth\n');
}).listen(1337, '0.0.0.0');
console.log('Server running at http://localhost:1337/');
console.log('Is anyone home?');
I set up coffee to watch and compile like so: coffee -wc -o js *.coffee &
OK that works fine, I see output like: 16:26:27 - compiled home.coffee
Then I go into the js directory and do this: nodemon *.js and the app starts:
15 Mar 16:24:03 - [nodemon] v0.6.12
15 Mar 16:24:03 - [nodemon] watching: /home/user/.gvfs/thesite on my-pc/js
15 Mar 16:24:03 - [nodemon] starting `node home.js`
Server running at http://localhost:1337/
Is anyone home?
Looks fine.
But when I make a change to the coffee file, nodemon doesn't do anything even though I can see that coffee is updating the home.js file in the js directory.
The file is on a gvfs share (gvfs = samba?). Could that be the issue?
Few questions:
The Samba mount might be the issue - but depends on your answers above.
Well, here's the cscript version anyway:
http = require('http')
http.createServer (req, res) ->
res.writeHead(200, {'Content-Type': 'text/plain'})
res.end('Hello Earth\n')
.listen(1337, '0.0.0.0')
console.log('Server running at http://localhost:1337/')
OK the spaces are messed up.
Yeah, the backtick in github flavoured markdown mean "code" - so they got ate.
Can I assume that Ubuntu is reading the Samba drive on a Windows machine (or is it just a regular drive?)?
Just tested it myself (on a mac - not with the mounts you've got setup) and it appears to work:
remy@remys-mba js $ nodemon *.js
16 Mar 00:05:20 - [nodemon] v0.6.12
16 Mar 00:05:20 - [nodemon] watching: /Users/remy/foo/js
16 Mar 00:05:20 - [nodemon] starting `node app.js`
Server running at http://localhost:1337/
00:05:41 - compiled app.coffee
16 Mar 00:05:42 - [nodemon] restarting due to changes...
16 Mar 00:05:42 - [nodemon] /Users/remy/foo/js/app.js
16 Mar 00:05:42 - [nodemon] starting `node app.js`
Server running at http://localhost:1337/
I do suspect it's the mount that might be the problem. I'm not quite sure how to start up a samba share (it's been a very long time!). I'm happy to pursue this if you can give me directions on how to replicate the issue.
Ah, the trick then is to do three backticks, a space, then a backtick.
Yes, the code is being modified on a Windows machine. But my coffee watch script is seeing the change, so that says the issue is not in the share. Is there a 'detail' mode in nodemon that might help?
Not really - and by not really - I mean: you'll have to change the code!
Before I get on to how to check, can you send me the result of this (in the VM):
node -e 'process.platform' -p
The monitoring happens on line 85 and 100 - depending on the system (which is why I'm after the value above): https://github.com/remy/nodemon/blob/master/nodemon.js#L85
You could sprinkle those functions with some console.logging?
I used this article:
http://www.7tutorials.com/how-access-windows-7-shared-folders-ubuntu
Then when I had the network path I went to ~/.gvfs and made a symlink. Nodemon is running inside of that symlink directory.
~/the_app> node -e 'process.platform' -p
Error: unrecognized flag -p
Try --help for options
linux
~/the_app>
Hmm, says "linux" so it means it's doing the changeFunction from line
I'll revisit in the morning - definitely an edge case, but happy to
try to get a fix in :)
Do let me know if you get to the bottom of it (assuming you're happy
to put a bunch of console.log in the nodemon.js file).
On 16 March 2012 00:16, Justin Collum
[email protected]
wrote:
~/the_app> node -e 'process.platform' -p
Error: unrecognized flag -p
Try --help for options
linux
~/the_app>
Reply to this email directly or view it on GitHub:
https://github.com/remy/nodemon/issues/74#issuecomment-4531927
OK I'll try that.
I added some logging, I have a lot of lines like this:
[ 'find -L "/home/user/.gvfs/the_app on justin-pc" -type f -mtime -50s -print' ]
starting changeFunction
[ 'find -L "/home/user/.gvfs/the_app on justin-pc" -type f -mtime -51s -print' ]
starting changeFunction
[ 'find -L "/home/user/.gvfs/the_app on justin-pc" -type f -mtime -52s -print' ]
They were causing an error so I did (95)
cmds.push('find -L "' + dir + '" -type f -mtime -' + ((+new Date - lastStarted)/1000|0) + ' -print');
There may be an issue with this line:
noWatch = (platform !== 'win32' && platform !== 'linux') || !fs.watch,
I'm not seeing .watch in the fs docs:
http://nodejs.org/docs/v0.4.9/api/fs.html
so I think this may always be false. I'm not real strong with js, so I could be wrong.
I think a large part of the issue was that when I installed node via apt-get it gave me an out of date version. Nvm did the trick there. Still ran into an issue though:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: require.paths is removed. Use node_modules folders, or the NODE_PATH environment variable instead.
at Function.<anonymous> (module.js:378:11)
at Object.<anonymous> (/home/user/bin/[email protected]:4:21)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Array.0 (module.js:479:10)
at EventEmitter._tickCallback (node.js:192:40)
after starting nodemon on a .coffee file. I reinstalled nodemon after upgrading to new version with nvm:
~> npm install nodemon -g
npm http GET https://registry.npmjs.org/nodemon
npm http 304 https://registry.npmjs.org/nodemon
/home/user/.nvm/v0.6.13/bin/nodemon -> /home/user/.nvm/v0.6.13/lib/node_modules/nodemon/nodemon.js
[email protected] /home/user/.nvm/v0.6.13/lib/node_modules/nodemon
I tried using Supervisor and it worked with no issues. Sorry :/
Hmm - I'm not aware of what nvm is - I assume this is some weird version of npm?
I think there's something funky about either the version node you're running or the setup - but if Supervisor works (and has the features you're after) then it's probably worth ending here.
Out of interest - what version of node did you settle on in the end?
NVM is essentially RVM for node. Easiest way I could find to get and manage
node versions. https://github.com/creationix/nvm
Ended up using v0.6.13.
On Fri, Mar 16, 2012 at 12:32 AM, Remy Sharp <
[email protected]
wrote:
Hmm - I'm not aware of what nvm is - I assume this is some weird version
of npm?I think there's something funky about either the version node you're
running or the setup - but if Supervisor works (and has the features you're
after) then it's probably worth ending here.Out of interest - what version of node did you settle on in the end?
Reply to this email directly or view it on GitHub:
https://github.com/remy/nodemon/issues/74#issuecomment-4535264
I've hit this same issue when trying to use nodemon to watch files that are on a non-local mounted file system. Using nodemon from Ubuntu64 10.04 to watch files that are mounted on a Windows 7 box, nodemon somehow doesn't see the file changes that happen on the Windows side. If I change those same files using vi on Ubuntu nodemon does see the change. I've tried both a smb/cifs mount and a vboxfs mount and they both act the same. I just tired using node-supervisor and that did work so I'll switch to that for now.
Voting to reopen. Looks like a legit issue instead of something funky in my setup.
@jcollum - agree. But I'll re-title as "can't read over unix -> windows mount".
Having the same problem too (ubuntu server on virtualbox that has access to windows shared folder)
Yes me too, using a Vagrant Ubuntu VM. But Node Supervisor does indeed work (https://github.com/isaacs/node-supervisor) So I'm using that one now.
nodemon -L did fix this, but I've extended the fix to make use of fs.watchFile over fs.watch so it should definitely work. Maybe worth checking today now (I've confirmed both work using Vagrant and shared drive).
FYI: I can validate this works, too. I ran into the same issue: Vagrant, CentOS guest on Ubuntu host. nodemon -L allowed nodemon to recognize changes across shared folders.
Most helpful comment
nodemon -Ldid fix this, but I've extended the fix to make use offs.watchFileoverfs.watchso it should definitely work. Maybe worth checking today now (I've confirmed both work using Vagrant and shared drive).