我试图解决的问题:
我在content.js:179 Uncaught ReferenceError: require is not defined
号线上遇到var wordnet =require('../node_modules/wordnet');
并且为了克服此错误,我尝试使用require.js。但是,我不确定如何在我的内容脚本中包含此脚本。
我已经在manifest.json中包含了require.js:
"content_scripts": [
{
"matches": [
"https://www.reddit.com/r/design_critiques/*"
],
"run_at": "document_end",
"js": [
"scripts/content.js",
"scripts/require.js"
],
"css": [
"stylesheets/content.css"
]
}]
答案 0 :(得分:0)
此问题的解决方案变得微不足道:在require.js
之前切换脚本以加载content.js
:
"content_scripts": [
{
"matches": [
"https://www.reddit.com/r/design_critiques/*"
],
"run_at": "document_end",
"js": [
"scripts/require.js",
"scripts/content.js"
],
"css": [
"stylesheets/content.css"
]
}]