[英]Manually adding method in a node module
我在我的網站上使用material-ui
,在npm
上找到的軟件包與最新版本(在Github上找到)已經過時。 我將這行代碼手動添加到其主題管理器類中,以反映更改:
setContentFontFamily(newContentFontFamily) {
if (typeof newContentFontFamily !== "undefined" && newContentFontFamily !== null) {
this.contentFontFamily = newContentFontFamily;
this.component = Extend(this.component, this.template.getComponentThemes(this.palette, this.spacing));
}
},
但是,我的應用程序尚未注冊這些更改,並且在嘗試設置字體時:
ThemeManager.setContentFontFamily('Open Sans, Roboto, sans serif');
控制台給我這個錯誤:
Uncaught TypeError: ThemeManager.setContentFontFamily is not a function
我正在使用Browserify捆綁客戶端的“需要”依賴項。 這是Browserify問題, npm
問題,還是我不了解節點模塊的工作方式?
編輯:這是我的package.json
{
"name": "FooProject",
"version": "0.0.0",
"description": "",
"dependencies": {
"highlight.js": "^8.7.0",
"material-ui": "callemall/material-ui",
"react": "^0.13.3",
"react-bootstrap": "^0.24.5",
"react-highlight": "^0.5.0",
"react-tap-event-plugin": "^0.1.7",
"underscore": "^1.8.3"
},
"author": "Tina Zheng",
"devDependencies": {
"babelify": "^6.1.3",
"bower": "^1.4.1",
"browserify": "^11.0.1",
"gulp": "^3.9.0",
"gulp-react": "^3.0.1",
"gulp-reactify": "^3.0.1"
}
}
解決問題的一種快速解決方案(除了聯系作者並要求他們更新npm之外)是使用存儲庫url作為依賴項而不是npm模塊:
git://github.com/user/project.git#commit-ish
如果存儲庫位於GitHub上,則可以使用縮寫形式:
"dependencies": {
"express": "visionmedia/express",
"mocha": "visionmedia/mocha#4727d357ea"
}
( docs )
如果您僅直接編輯依賴項,則每次重新構建時它們都會被覆蓋。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.