1.5.2 b2 报错 'import' and 'export' may appear only with 'sourceType: module

1.5.2 b2 报错 ‘import’ and ‘export’ may appear only with 'sourceType: module

就是打开编辑器时报的错

你展开这个报错,看看是import哪个文件,看看是不是有地方import这个代码的时候文件名大小写不对

麻烦把完整的报错信息贴上来,谢谢。

建议:按照楼上的建议查看一下那个文件import出现问题了。

Compile error: ‘import’ and ‘export’ may appear only with ‘sourceType: module’
D:\WorkSpace\sanguoMobile\h5clientTS\assets\script\game\vo\mainCity\MainCityVO.ts:1
import {Data} from “…/…/utils/bind/Data”;
^
ParseError: ‘import’ and ‘export’ may appear only with ‘sourceType: module’
at Readable. (F:\CocosCreator\1.5.2 beta.2\resources\app.asar\editor\page\compile-worker.js:1:2899)
at emitOne (events.js:101:20)
at Readable.emit (events.js:188:7)
at Labeled. (F:\CocosCreator\1.5.2 beta.2\resources\app.asar\node_modules\read-only-stream\index.js:28:44)
at emitOne (events.js:96:13)
at Labeled.emit (events.js:188:7)
at Labeled. (F:\CocosCreator\1.5.2 beta.2\resources\app.asar\node_modules\stream-splicer\index.js:130:18)
at emitOne (events.js:101:20)
at Labeled.emit (events.js:188:7)
at DestroyableTransform. (F:\CocosCreator\1.5.2 beta.2\resources\app.asar\node_modules\stream-splicer\index.js:130:18)
at F:\CocosCreator\1.5.2 beta.2\resources\app.asar\editor\core\compiler.js:1:1092
at F:\CocosCreator\1.5.2 beta.2\resources\app.asar\editor\core\compiler.js:1:492
at BrowserWindow. (F:\CocosCreator\1.5.2 beta.2\resources\app.asar\editor\core\compiler.js:1:2305)
at BrowserWindow.g (events.js:286:16)
at emitOne (events.js:101:20)
at BrowserWindow.emit (events.js:188:7)

按照@toddlxt 说的还是不行,文件名大小写都正确

应该说大部分文件都出现了这个问题,把报错的文件导入去掉以后,下一个又有了

麻烦提交一个 demo 我试试

这个抱歉,弄了个新项目没重现出来,公司项目里出现的问题,我自己找找原因吧

好的没关吸

我升级beta.2的时候遇到过同样问题,你检查一下…/…/utils/bind/Data这个路径正不正确,有没有大小写不一致的地方,比如是不是…/…/utils/bind/data。之前大小写不一致也可以编译,可能这个版本改动了Babel,检查变严格了

好的,我是把路径完全改了,就可以了

找找项目文件夹的上一级目录里面有没有同名的文件。我今天也遇到了这个问题,最后发现是我把脚本文件夹复制到了项目的上级目录,忘了删除,结果打包的时候报了这个错