简体   繁体   中英

Errors with Vagrant and javascript possibly due to line endings

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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM