2022-03-31 Failed to minify the code from this file
阿新 • • 發佈:2022-03-31
前言:專案打包報錯。
報錯內容:
1 Creating an optimized production build... 2 Failed to compile. 3 4 Failed to minify the code from this file: 5 6 ./node_modules/[email protected]@asn1.js/lib/asn1/base/node.js:283 7 8 Read more here: http://bit.ly/2tRViJ9 9 10 npm ERR! code ELIFECYCLE 11 npm ERR! errno 1 12 npm ERR! [email protected] build: `node scripts/build.js` 13npm ERR! Exit status 1 14 npm ERR! 15 npm ERR! Failed at the [email protected] build script. 16 npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 17 18 npm ERR! A complete log of this run can be found in: 19 npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2022-03-31T08_22_24_542Z-debug.log
解決方案:
關鍵內容:
Failed to minify the code from this file: ./node_modules/[email protected]@asn1.js/lib/asn1/base/node.js:283
翻譯:未能縮小此檔案【./node_modules/[email protected]@asn1.js/lib/asn1/base/node.js:283】中的程式碼
原因:該檔案裡的程式碼無法被打包,定位到該行程式碼: 【let result = state['default'];】
解決方案:把let改為var。
結束語:
不要問我為什麼,我也是找了篇文章看了才解決的,後續打包也是遇到這個問題,我依舊把let改成var就行了。
據原文作者說是es6轉不了es5,也許就是這個原因吧。
原文在這:https://blog.csdn.net/u010391930/article/details/118188243
額嗯呃emmmm,其實,額,怎麼說呢。
在我快寫完這個日誌的時候,我同事告訴我,這個專案其實已經打包成功了。也就是說,可以不用理會這種報錯。。。
emmm...