我使用cosmos在浏览器中安装React-masonry-component时遇到问题:浏览器化。错误消息表明没有兼容版本的组件依赖,砌体,可以找到(在npm,我相信)。相同的反应包似乎在使用Webpack的常规节点项目中工作,这就是为什么我认为这个问题是特定于Meteor的。
这是我的packages.json文件。
{
"externalify": "0.1.0",
"react-router": "0.13.3",
"react-pixi": "0.6.1",
"radium": "0.13.4",
"griddle-react": "0.2.13",
"react-masonry-component": "1.0.1"
}
app.browserify.js
ReactRouter = require("react-router");
ReactPIXI = require("react-pixi");
Radium = require("radium");
Griddle = require("griddle-react");
Masonry = require("react-masonry-component");
构建过程中的错误消息
=> Modified -- restarting.
npm-container: updating npm dependencies -- externalify, react-router,
react-pixi, radium, griddle-react, masonry-layout, imagesloaded,
react-masonry-component...
npm ERR! Windows_NT 6.2.9200
npm ERR! argv
"C:\\Users\\Nick\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.1.4\\mt- os.windows.x86_32\\dev_bundle\\bin\\\\node.exe"
"C:\\Users\\Nick\\AppData\\Local\\.meteor\\packages\\meteor-tool\\1.1.4\\mt-os.windows.x86_32\\dev_bundle\\bin\\node_modules\\npm\\bin\\npm-cli.js"
"install" "react-masonry-component@1.0.1"
npm ERR! node v0.10.36
npm ERR! npm v2.7.3
npm ERR! code ETARGET
npm ERR! notarget No compatible version found:
masonry@'git+ssh://git@github.com/eiriklv/masonry.git'
**npm ERR! notarget Valid install targets:
npm ERR! notarget ["0.0.1","0.0.2"]
npm ERR! notarget
npm ERR! notarget This is most likely not a problem with npm itself.
npm ERR! notarget In most cases you or one of your dependencies are
requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of
'react-masonry-component'
npm ERR! notarget
=> Errors prevented startup:
While building package npm-container:
error: couldn't install npm package
=> Your application has errors. Waiting for file change.
答案 0 :(得分:1)
由于Meteorhacks:npm需要npm或github模块的特定版本/提交,因此Meteor构建过程无法包含此React-Masonry-Component,其package.json定义依赖项而不引用特定提交。例如,
"dependency": {"masonry" = "eirik/masonry"}
为了避免这个问题,我分叉了Eirik的npm模块并发布了一个版本,该版本定义了所有与特定npm版本或github提交的依赖关系。例如,
"dependency": {"masonry" = "https://github.com/eirik/masonry/archive/dd74b7c6fe58e9f5de56d2ab442ac4b2d0fa5dd1.tar.gz"}
有关此要求的详细信息,请参阅https://github.com/meteorhacks/npm。
现在代码可以使用以下设置:
packages.json
"react-masonry-component-4meteorhacks-npm": "0.0.13"
app.browserify.js
Masonry = require("react-masonry-component-4meteorhacks-npm")(React);