程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Module build failed (from./node_modules/highlight.js/lib/languages/python.js

編輯:Python

I'm just going to do a blog project these days , Then I added a few blogs in the background , Then introduce the marked and highlight.js No problem . Used backstage vue. Then yesterday, I was going to do a blog for the client , That's the mistake , The hint is that my module highlight.js Compile failed .
Then we will discuss how to solve various searches .
There has been no way .
Guess if the module error is .js But obviously not , I import it according to the package in the background , And the wrong guide is not such a mistake , It's not a version issue , After all, if the backstage can be used , The version of the follow-up package should not matter much .
And when I opened the project this morning , Another error occurred suddenly in the compilation , Say my antd Can't find package.json, I wondered , I haven't even moved , Later I thought about , For the front desk umi+ts, And package manager yarn, But it was installed yesterday marked and highlight.js It seems to be used npm, Just thinking that there was a mistake, I would reload the bag . Sure enough, it's useless .

The key is coming. , Suddenly something came to mind , Before I think about it webpack It's like learning a configuration , Yes, external import can be configured js. I suddenly feel webpack How useful , So I went to the official website umi To see how to match , I also saw webpack Configuration of , The configuration found is externals.

externals : {

'highlight.js' : "window.hljs"
},
scripts : ["https://cdn.bootcdn.net/ajax/libs/highlight.js/11.4.0/highlight.min.js"]

Because there is umi Yes scripts Configuration item , So I didn't move umi Compile template for .
Here's to say umi Of html Templates
stay src/pages Create... Under the directory document.ejs File can rewrite template file

Because there is still no solution to the problem , But it also provides a comparison flexible The idea of , When the template compilation fails , If time is tight , You can try to configure the external cdn link , Import code from elsewhere , Expose global variables , And pass externals Configure import package not to compile , And tell how the variables are exposed .

If a friend knows the nature of this mistake , Feel free to leave a comment below .


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved