Hidden characters '\u0' added to file after save on server

我们两清 提交于 2019-12-05 01:06:34

问题


I'm using an Apache server to serve websites for web development. That way i'm constantly saving and editing files.

I'm using Gulp for Sass and to concat and uglify css and js files.

A month ago i'm experiencing problems with my js and css files. It seems that there are randomly generated '\u0' characters added below the files.

These characters are not visible in the code editor only in the browser inspect:

Chrome says: SyntaxError: Invalid or unexpected token Firefox says: 'SyntaxError: illegal character'

I can see the characters also when opening CSS/SCSS files. CSS is forgiving and keeps working. JS stops working when the characters are added.

The problem never happens when a file is empty. But if there is only when simple line of code (for example: console.log('test');) the problem can occur.

My first bet was here: No visible cause for "Unexpected token ILLEGAL" Although i could successfully change the apache config the problem would still persist.

I have no idea if this is a Gulp related issue or a Apache related issue. Even the gulpfile.js itself sometimes has these hidden characters added. So it's probably not related to gulp?

I found a way to create files without the hidden characters. First I have to delete the content of the file entirely. Then save it. Then add the lines I wanted to create. Only the very first time when saving this will work. When i save again, the hidden characters are added again.

Sounds like a cache problem i thought. But i tried everything from disabling cache in apache to removing all cache from browser. Nothing seems to work.

Help me internet, you are my only hope.

update: After some more trial and error i decided to change from SMB to AFP. This seems to help.

来源:https://stackoverflow.com/questions/45280790/hidden-characters-u0-added-to-file-after-save-on-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!