前言
我是一个新手,在webpack使用art-template时,出现了"can’t resoleve ‘…\lib\runtime.js’''的问题,研究了很久很久,不得不说,百度这个东西除了搜索套娃文章和广告,真…啥也不是.
问题再现
在webpack使用art-template编译时,出现了类似如下错误:
ERROR in Error: Child compilation failed:
Module not found: Error: Can't resolve '..\..\node_modules\art-template\lib\runtime.js' in 'D:\xxx\xxx\xxxx'
Did you mean './..\..\node_modules\art-template\lib\runtime.js'?
Requests that should resolve in the current directory need to start with './'.
Requests that start with a name are treated as module requests and resolve within module directories (node_modules).
......
当时看上去可能是路径或者node_modules出现了问题, 经过多次测试排除, 又换webpack和art-template版本…一系列操作后总结发现三点问题:
-
所有art文件在根目录第一层文件夹下,比如’./src/xxx.art’, 或者’./components/xxx.art’,就不会出错.
-
问题只出现在新版webpack上,也有可能是template,或者他们俩都有问题.忘记了,大概是这样.
-
也许是win11或者win10下独有问题
研究了好久,又查百度,还是没找到解决办法就放弃了,过了一段时间又感觉不找到解决办法还是难受,间接导致阳痿早泄…想起google,github搜一下…终于找到了解决办法
解决办法
已知解决此问题无效的方法: 全局安装npm -g i art-template
把art-template里的lib文件夹拷贝到项目所在磁盘根目录,比如你的项目在c盘,要保证能有c:\node_modules\art-template\lib可以访问.