我分叉了一个npm模块,现在它是一个git repo.
所以我的package.json:
"dependencies": {
"some-module": "git+https://github.com/my-name/some-module.git",
}
Run Code Online (Sandbox Code Playgroud)
通过获取上游和合并来同步forked repo.但是当我尝试更新其他npm模块时,它会给出错误:
npm ERR! git Appears to be a git repo or submodule.
npm ERR! git /Users/.../node_modules/some-module
npm ERR! git Refusing to remove it. Update manually,
npm ERR! git or move it out of the way first.
npm ERR! System Darwin 13.4.0
npm ERR! command "node" "/usr/local/bin/npm" "update"
npm ERR! cwd /Users/...
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! path /Users/.../node_modules/some-module
npm ERR! code EISGIT
npm ERR! …Run Code Online (Sandbox Code Playgroud) 在使用LoopbackJS的Node.js项目构建中,我需要在请求期间存储数据.
所以我使用了域名功能:
// pre-processing middleware
app.use(function (req, res, next) {
// create per request domain instance
var domain = require('domain').create();
// save request and response to domain, to make it accessible everywhere
domain.req = req;
domain.res = res;
domain.run(next);
});
Run Code Online (Sandbox Code Playgroud)
稍后在必修单元中:
Model.beforeRemote('**', function(oContext, oModel, next) {
// Save method name for later use
process.domain.remoteContext = { /* Here is an error thrown */
methodName: oContext.method.name
};
...
process.domain.res.send() // example of usage
})
Run Code Online (Sandbox Code Playgroud)
但是当我从Safari或IE发出请求时,process.domain有时是未定义的!Chrome或Firefox的请求按预期工作.有什么建议?
错误回复:
{"error":{"name":"TypeError","status":500,"message":"Cannot set property …Run Code Online (Sandbox Code Playgroud) 我有关系数据库的用户模型.
每个用户都可以拥有"chiefId"为FK的"用户".
"relations": {
"users": {
"type": "hasMany",
"model": "User",
"foreignKey": "chiefId"
},
}
Run Code Online (Sandbox Code Playgroud)
我可以查询每个主要用户的相关用户,如下所示:
GET /users?filter={"include":"users"}
Run Code Online (Sandbox Code Playgroud)
但它返回完整的用户对象.