error in ./node_modules/yargs/lib/platform-shims/esm.mjs
Module parse failed: Unexpected token (18:41)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| const REQUIRE_DIRECTORY_ERROR = 'loading a directory of commands is not supported yet for ESM'
|
> const mainFilename = fileURLToPath(import.meta.url).split('node_modules')[0]
| const __dirname = fileURLToPath(import.meta.url)
|
背景
基于Vue-element-admin的后臺(tái)管理項(xiàng)目:在使用element下拉菜單綁定一個(gè)辦法時(shí)候,運(yùn)行報(bào)錯(cuò)。報(bào)錯(cuò)截圖如下。



解決思路
借助網(wǎng)上搜索,發(fā)現(xiàn)是webpack缺失一個(gè)loader加載器,網(wǎng)上其他博客的解決方法都是在webpack.js里面進(jìn)行修改代碼??墒俏疫@個(gè)是基于vue-element-admin的后臺(tái)管理項(xiàng)目,只有webpack.json,此時(shí)我的思路陷入了僵局......
但是我又在想,之前都能正常運(yùn)行的程序,咋我綁定了一個(gè)方法,就不行了嘞。
于是,把我寫的幾句代碼慢慢注釋掉,定位是哪里的問題。
接著回看代碼...
??果然??!寫command的時(shí)候,vscode偷偷給我引入了command方法??。注釋掉以后,重啟項(xiàng)目后,不報(bào)錯(cuò)了可以運(yùn)行了。

總結(jié)文章來源:http://www.zghlxwxcb.cn/news/detail-456011.html
回看自己寫的糟心代碼也很重要 :)文章來源地址http://www.zghlxwxcb.cn/news/detail-456011.html
到了這里,關(guān)于編譯報(bào)錯(cuò):Module parse failed: Unexpected token (18:41)的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!