小编Iva*_*nZh的帖子

如何更新npm模块,忽略git repo

我分叉了一个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)

git npm

25
推荐指数
4
解决办法
1万
查看次数

Node.js process.domain有时是未定义的

在使用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)

node.js

6
推荐指数
1
解决办法
2466
查看次数

Loopback 2.4:如何通过REST API查询相关模型的某些字段

我有关系数据库的用户模型.

每个用户都可以拥有"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)

但它返回完整的用户对象.

  • 我该如何仅查询相关用户的"名称"属性?
  • 是否可以在一个请求中计算相关实例到服务器?

jugglingdb strongloop loopbackjs

5
推荐指数
1
解决办法
3740
查看次数

标签 统计

git ×1

jugglingdb ×1

loopbackjs ×1

node.js ×1

npm ×1

strongloop ×1