0

I am trying to set up a Vagrant dev environment that I can re use. I am having a lot of problems using NPM and specifically Browserify.

Whenever I run browserify to bundle js files. It works ok the first time after git cloning my repo, but if I then edit the files on my windows machine (or my mac). I start getting errors in javascript files:

Uncaught SyntaxError: Unexpected token ILLEGAL

I am sure this is to do with line endings but have so far been unable to fix it. I have tried setting git config settings as follows:

git config --global core.autocrlf false

Have tried various values for the above command with no luck. I also tried setting eol for file types within .gitattributes like this:

*.js text eol=lf

...but am now getting to the point where I am a bit lost. Has anyone experienced similar issues and had any luck with a solution?

Steven1978
  • 476
  • 1
  • 3
  • 15

2 Answers2

2

After pulling my hair out for around 4 days over this, I found what appears to be the solution here:

No visible cause for "Unexpected token ILLEGAL"

I need to set sendfile to off:

sendfile off;

... in my nginx.conf file on the vm. This fixes the issue I was having.

Community
  • 1
  • 1
Steven1978
  • 476
  • 1
  • 3
  • 15
0

I faced the same issue and as far as i remember i resolved it by changing the line endings from windows to unix. So my suggestion is to change the line endings to be unix in your preferred editor.

Endre Simo
  • 11,330
  • 2
  • 40
  • 49
  • It's very strange. I have done this already. I use phpstorm and the only line endings settings it has are related to git which I have set as specified in the git docs (git config --global core.autocrlf true). If I check out my project, run browserify, all works fine, but then if I edit the files locally in phpstorm or even within the VM in vim and run browserify again, I get the error again. Surely it should be ok if I edited the file in vim within the Ubuntu VM?? – Steven1978 Jan 11 '16 at 10:29