我正在尝试加载sentiment module,在我的content.js中使用require.js解释in this doc:
require(['./require', '../node_modules/sentiment'], function (require) {
//sentiment is now loaded.
var sentiment = require('../node_modules/sentiment');
if (sentiment) {
console.log('sentiment module loaded');
}
});
没有控制台错误,所以我不完全确定为什么没有打印到控制台或如何解决此问题。
编辑: 这是我的清单:
{
"manifest_version": 2,
"name": "CA-extension",
"version": "2.0",
"page_action": {
"default_popup": "views/popup.html",
"default_title": "CA-extension"
},
"options_page": "views/options.html",
"background": {
"scripts": [
"scripts/background.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"
]
}
],
"permissions": [
"storage",
"tabs",
"https://www.reddit.com/r/design_critiques/*"
],
"web_accessible_resources": [
"views/options.html",
"https://www.reddit.com/r/design_critiques/*"
]
}