gpt4 book ai didi

angular - WebStorm (v2.3.1) : Live reload after file change (html) does not work. SyntaxError: Unexpected token < in JSON at position 0

转载 作者:太空狗 更新时间:2023-10-29 17:15:39 33 4
gpt4 key购买 nike

Initial seed ,什么都没有改变。

Windows 7、npm 4.0.1、节点 v6.8.1、TypeScript 2.0.10

这是 Chrome 控制台(屏幕截图):

Google Chrome Console Output

VM661:1 Uncaught SyntaxError: 
Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at http://localhost:5555/app/system-config.js:1:20
(anonymous function) @ system-config.ts:2

在重新加载时 '<%= SYSTEM_CONFIG_DEV %>'无法解释,无论问题是什么,都与时间或顺序有关。

留言 Unexpected token <代表 <'<%= SYSTEM_CONFIG_DEV %>'
WebStorm TypeScript 设置:

enter image description here

WebStorm“安全写入”已激活:

enter image description here

进一步调查 (23.12.2017):

我们仍然有这个问题,禁用 TypeScript Compiler 并不能解决问题。

问题的起点在这里( src/client/app/system-config.ts ):
System.config(JSON.parse('<%= SYSTEM_CONFIG_DEV %>'));

此模板以 <%= ... 开头在 html 更改后重新加载时未评估:
'<%= SYSTEM_CONFIG_DEV %>'

那是什么样的模板? EJS ?种子中的这种依赖性在哪里?我有两个怀疑:

1) Windows 上的 Express 服务器在重新加载 EJS 模板时有问题?

2) EJS 不会因为 js-libraries 的注入(inject)顺序被评估?

最佳答案

我修改了 start.deving.ts现在它也适用于 Windows:

gulp.task('watch.while_deving', function () {
watchAppFiles('**/!(*.ts)', (e: any, done: any) =>
runSequence('build.assets.dev', 'build.html_css', 'build.js.dev', 'build.index.dev', () => { notifyLiveReload(e); done(); }));
watchAppFiles('**/(*.ts)', (e: any, done: any) =>
runSequence('build.js.dev', 'build.index.dev', () => {
notifyLiveReload(e);
runSequence('build.js.test', 'karma.run.with_coverage', done);
}));
});

试试看: npm run start.deving

关于angular - WebStorm (v2.3.1) : Live reload after file change (html) does not work. SyntaxError: Unexpected token < in JSON at position 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40805944/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com