javascript - 在 Openshift 上运行 MEAN 站点时出现非常奇怪的 Mongoose/MongoDB 问题

标签 javascript node.js mongodb express mongoose

我已将网站上传到 Openshift...我必须进行许多更改...包括学习版本控制和 nvm( Node 版本管理器)。我必须经历很多 npm 版本的东西才能使请求发生(即,服务器使用 Express 版本 3.2.5,而我在本地使用 4.2.0)。不管怎样,现在我遇到了这个奇怪的问题, Mongoose 函数 - Model.findById()似乎根本无法通过 _id 找到数据库中明确存在的对象属性。流程是这样的(您可以在这里亲自查看 - http://hackabox-eamonbenproject.rhcloud.com - 我的项目):

当我尝试在可以查看所有帖子信息的页面上加载帖子时...GET请求发生,这里通过express调用一个路由:

app.get('/api/posts/:id', api.showinfo);

那个api.showinfo目前的功能是这样的(尽管我尝试了很多不同的事情):

exports.showinfo = function(req, res, next) {
  var postId = req.params.id;

  Post.findById(postId, function (err, post) {
    console.log("what did u find?" + post);
    res.send({ postinfo: post.postinfo });
    //res.json(post);
  });
};

那个console.log("what did u find?" + post)输出null ,这意味着带有 mongoose 的 findById 的东西功能出了问题。

我已登录以确保 postId是正确的 id...所以这不是问题。我也尝试过改变res.send({ postinfo: post.postinfo });res.json(post) , res.send(post.postinfo) , res.send({ profile: post.postinfo }) - 运气不好。

有谁知道为什么findById可能找不到任何东西... post.postinfo指的是我的 Mongoose 虚拟架构,如下所示:

PostSchema
  .virtual('postinfo')
    .get(function() {
      return {
        '_id': this._id,
        'posttitle': this.posttitle,
        'content': this.content,
        'username': this.username,
        'date': this.date
      };
    });

我想将它与 res.send 一起使用它如何在我的种子中的用户身份验证系统中使用可能会起作用 - 它是这样使用的 - 并且它工作得很好:

exports.show = function (req, res, next) {
  var userId = req.params.id;

  User.findById(userId, function (err, user) {
    if (err) return next(err);
    if (!user) return res.send(404);

    res.send({ profile: user.profile });
  });
};

出于某种原因,当我将它与 Post 一起使用时我制作的模型,它不想在 Openshift 上工作,我很确定它可以在本地工作。

有什么想法吗?

更新

将我的 MongoDB 版本本地降级到 2.4.6(与 openshift 服务器版本相同)后 - 该站点开始在本地遇到与服务器上相同的问题...所以这绝对是一个环境问题 - 我猜测一些依赖 Mongo 的包也需要更改其版本 - 所以我将尝试一下,看看是否有帮助。当我现在在本地运行它时,这似乎是种子内版本冲突的问题 - 这是我的 package.json 中所有与 mongo 相关的 npm 包文件:

{
  "name": "hackabox",
  "version": "0.0.0",
  "dependencies": {

    ...

    "mongoose": "~3.8.8",
    "connect-mongo": "mrzepinski/connect-mongo#2135988",

    ...
  },

  ...

}

有谁知道 MongoDB v2.4.6 使用什么版本?

更新

我尝试了 Mongoose v3.5.0,但它不起作用 - 我正在查看提交日期,似乎是在 MongoDB v2.4.6 发布的时间左右。还需要更新/降级哪些其他软件包才能与 openshift 服务器同步?

更新

做了一些事情,但没有运气 - 但最终我最终通过 ssh 进入 openshift 服务器并运行:

npm list -g --depth=0

它回复了 EACCES错误 - 但它也吐出了所有版本号 - 所以它们是:

glob error { [Error: EACCES, readdir '/opt/rh/nodejs010/root/usr/lib/node_modules/npm/man']
  errno: 3,
  code: 'EACCES',
  path: '/opt/rh/nodejs010/root/usr/lib/node_modules/npm/man' }
/opt/rh/nodejs010/root/usr/lib
├── abbrev@1.0.4
├── ansi@0.2.1
├── ansicolors@0.3.2
├── ansistyles@0.1.3
├── archy@0.0.2
├── asn1@0.1.11
├── assert-plus@0.1.4
├── async@0.2.9
├── aws-sign@0.3.0
├── bignumber.js@1.1.1
├── block-stream@0.0.7
├── boom@0.4.2
├── bson@0.2.3
├── buffer-crc32@0.2.1
├── bytes@0.2.1
├── child-process-close@0.1.1
├── chmodr@0.1.0
├── chownr@0.0.1
├── cmd-shim@1.1.0
├── colors@0.6.2
├── columnify@0.1.2
├── combined-stream@0.0.4
├── commander@1.1.1
├── config-chain@1.1.8
├── connect@2.7.10
├── cookie@0.1.0
├── cookie-jar@0.3.0
├── cookie-signature@1.0.1
├── couch-login@0.1.18
├── cryptiles@0.2.2
├── ctype@0.5.3
├── debug@0.7.2
├── delayed-stream@0.0.5
├── editor@0.0.5
├── express@3.2.5
├── forever-agent@0.5.0
├── form-data@0.1.1
├── formidable@1.0.14
├── fresh@0.2.0
├── fstream@0.1.25
├── fstream-ignore@0.0.7
├── fstream-npm@0.1.6
├── generic-pool@2.0.3
├── github-url-from-git@1.1.1
├── github-url-from-username-repo@0.0.2
├── glob@3.2.8
├── graceful-fs@2.0.0
├── hawk@1.0.0
├── hoek@0.9.1
├── http-signature@0.10.0
├── inherits@2.0.0
├── ini@1.1.0
├── init-package-json@0.0.14
├── json-stringify-safe@5.0.0
├── keypress@0.2.1
├── lockfile@0.4.2
├── lru-cache@2.5.0
├── methods@0.0.1
├── mime@1.2.11
├── minimatch@0.2.14
├── mkdirp@0.3.5
├── mongodb@1.3.19
├── mute-stream@0.0.4
├── mysql@2.0.0-alpha9
├── nan@0.4.4
├── node-gyp@0.12.2
├── node-static@0.6.9
├── node-uuid@1.4.1
├── nopt@2.1.2
├── normalize-package-data@0.2.8
├── npm@*
├── npm-registry-client@0.3.3
├── npm-user-validate@0.0.3
├── npmconf@0.1.12
├── npmlog@0.0.6
├── oauth-sign@0.3.0
├── once@1.3.0
├── opener@1.3.0
├── openshift-node-web-proxy@*
├── optimist@0.4.0
├── options@0.0.5
├── osenv@0.0.3
├── path-is-inside@1.0.0
├── pause@0.0.1
├── pg@0.12.3
├── promzard@0.2.0
├── proto-list@1.2.2
├── qs@0.6.5
├── range-parser@0.0.4
├── read@1.0.5
├── read-installed@0.2.4
├── read-package-json@1.1.6
├── request@2.25.0
├── require-all@0.0.8
├── retry@0.6.0
├── rimraf@2.2.6
├── semver@2.1.0
├── send@0.1.4
├── sha@1.2.1
├── sigmund@1.0.0
├── slide@1.1.5
├── sntp@0.2.4
├── supervisor@0.5.2
├── tar@0.1.19
├── text-table@0.2.0
├── tinycolor@0.0.1
├── tunnel-agent@0.3.0
├── uid-number@0.0.3
├── which@1.0.5
├── wordwrap@0.0.2
└── ws@0.4.25

我真的需要让我的所有全局 npm 包与 openshift 上的包版本相同,以确保它可以工作(对于相关的包)吗?

我跑了npm list -g本地 - 这就是我得到的:

/usr/lib
├─┬ bower@1.3.3
│ ├── abbrev@1.0.5
│ ├── archy@0.0.2
│ ├─┬ bower-config@0.5.0
│ │ ├── mout@0.6.0
│ │ └─┬ optimist@0.6.1
│ │   ├── minimist@0.0.8
│ │   └── wordwrap@0.0.2
│ ├── bower-endpoint-parser@0.2.1
│ ├─┬ bower-json@0.4.0
│ │ ├── deep-extend@0.2.8
│ │ └── intersect@0.0.3
│ ├── bower-logger@0.2.2
│ ├─┬ bower-registry-client@0.2.0
│ │ ├── async@0.2.10
│ │ ├─┬ bower-config@0.4.5
│ │ │ ├── mout@0.6.0
│ │ │ └─┬ optimist@0.6.1
│ │ │   ├── minimist@0.0.8
│ │ │   └── wordwrap@0.0.2
│ │ ├── lru-cache@2.3.1
│ │ ├─┬ request@2.27.0
│ │ │ ├── aws-sign@0.3.0
│ │ │ ├── cookie-jar@0.3.0
│ │ │ ├── forever-agent@0.5.2
│ │ │ ├─┬ form-data@0.1.2
│ │ │ │ └─┬ combined-stream@0.0.4
│ │ │ │   └── delayed-stream@0.0.5
│ │ │ ├─┬ hawk@1.0.0
│ │ │ │ ├── boom@0.4.2
│ │ │ │ ├── cryptiles@0.2.2
│ │ │ │ ├── hoek@0.9.1
│ │ │ │ └── sntp@0.2.4
│ │ │ ├─┬ http-signature@0.10.0
│ │ │ │ ├── asn1@0.1.11
│ │ │ │ ├── assert-plus@0.1.2
│ │ │ │ └── ctype@0.5.2
│ │ │ ├── json-stringify-safe@5.0.0
│ │ │ ├── mime@1.2.11
│ │ │ ├── node-uuid@1.4.1
│ │ │ ├── oauth-sign@0.3.0
│ │ │ ├── qs@0.6.6
│ │ │ └── tunnel-agent@0.3.0
│ │ └── request-replay@0.2.0
│ ├─┬ cardinal@0.4.4
│ │ ├── ansicolors@0.2.1
│ │ └─┬ redeyed@0.4.4
│ │   └── esprima@1.0.4
│ ├─┬ chalk@0.4.0
│ │ ├── ansi-styles@1.0.0
│ │ ├── has-color@0.1.7
│ │ └── strip-ansi@0.1.1
│ ├── chmodr@0.1.0
│ ├─┬ decompress-zip@0.0.6
│ │ ├─┬ binary@0.3.0
│ │ │ ├── buffers@0.1.1
│ │ │ └─┬ chainsaw@0.1.0
│ │ │   └── traverse@0.3.9
│ │ ├── mkpath@0.1.0
│ │ ├─┬ readable-stream@1.1.13-1
│ │ │ ├── core-util-is@1.0.1
│ │ │ ├── inherits@2.0.1
│ │ │ ├── isarray@0.0.1
│ │ │ └── string_decoder@0.10.25-1
│ │ └─┬ touch@0.0.2
│ │   └── nopt@1.0.10
│ ├─┬ fstream@0.1.25
│ │ └── inherits@2.0.1
│ ├─┬ fstream-ignore@0.0.7
│ │ ├── inherits@2.0.1
│ │ └─┬ minimatch@0.2.14
│ │   └── sigmund@1.0.0
│ ├─┬ glob@3.2.9
│ │ ├── inherits@2.0.1
│ │ └─┬ minimatch@0.2.14
│ │   └── sigmund@1.0.0
│ ├── graceful-fs@2.0.3
│ ├─┬ handlebars@1.3.0
│ │ ├─┬ optimist@0.3.7
│ │ │ └── wordwrap@0.0.2
│ │ └─┬ uglify-js@2.3.6
│ │   ├── async@0.2.10
│ │   └─┬ source-map@0.1.33
│ │     └── amdefine@0.1.0
│ ├─┬ inquirer@0.4.1
│ │ ├── async@0.2.10
│ │ ├─┬ cli-color@0.2.3
│ │ │ ├── es5-ext@0.9.2
│ │ │ └─┬ memoizee@0.2.6
│ │ │   ├── event-emitter@0.2.2
│ │ │   └── next-tick@0.1.0
│ │ ├── lodash@2.4.1
│ │ ├── mute-stream@0.0.4
│ │ ├── readline2@0.1.0
│ │ └── through@2.3.4
│ ├─┬ insight@0.3.1
│ │ ├── async@0.2.10
│ │ ├─┬ configstore@0.2.3
│ │ │ ├─┬ js-yaml@3.0.2
│ │ │ │ ├─┬ argparse@0.1.15
│ │ │ │ │ ├── underscore@1.4.4
│ │ │ │ │ └── underscore.string@2.3.3
│ │ │ │ └── esprima@1.0.4
│ │ │ └── uuid@1.4.1
│ │ ├─┬ lodash.debounce@2.4.1
│ │ │ ├── lodash.isfunction@2.4.1
│ │ │ ├─┬ lodash.isobject@2.4.1
│ │ │ │ └── lodash._objecttypes@2.4.1
│ │ │ └─┬ lodash.now@2.4.1
│ │ │   └── lodash._isnative@2.4.1
│ │ ├── object-assign@0.1.2
│ │ └─┬ request@2.27.0
│ │   ├── aws-sign@0.3.0
│ │   ├── cookie-jar@0.3.0
│ │   ├── forever-agent@0.5.2
│ │   ├─┬ form-data@0.1.2
│ │   │ └─┬ combined-stream@0.0.4
│ │   │   └── delayed-stream@0.0.5
│ │   ├─┬ hawk@1.0.0
│ │   │ ├── boom@0.4.2
│ │   │ ├── cryptiles@0.2.2
│ │   │ ├── hoek@0.9.1
│ │   │ └── sntp@0.2.4
│ │   ├─┬ http-signature@0.10.0
│ │   │ ├── asn1@0.1.11
│ │   │ ├── assert-plus@0.1.2
│ │   │ └── ctype@0.5.2
│ │   ├── json-stringify-safe@5.0.0
│ │   ├── mime@1.2.11
│ │   ├── node-uuid@1.4.1
│ │   ├── oauth-sign@0.3.0
│ │   ├── qs@0.6.6
│ │   └── tunnel-agent@0.3.0
│ ├── is-root@0.1.0
│ ├── junk@0.3.0
│ ├── lockfile@0.4.2
│ ├── lru-cache@2.5.0
│ ├── mkdirp@0.3.5
│ ├── mout@0.9.1
│ ├── nopt@2.2.0
│ ├── opn@0.1.1
│ ├── osenv@0.0.3
│ ├─┬ p-throttler@0.0.1
│ │ └── q@0.9.7
│ ├─┬ promptly@0.2.0
│ │ └─┬ read@1.0.5
│ │   └── mute-stream@0.0.4
│ ├── q@1.0.1
│ ├─┬ request@2.34.0
│ │ ├── aws-sign2@0.5.0
│ │ ├── forever-agent@0.5.2
│ │ ├─┬ form-data@0.1.2
│ │ │ ├── async@0.2.10
│ │ │ └─┬ combined-stream@0.0.4
│ │ │   └── delayed-stream@0.0.5
│ │ ├─┬ hawk@1.0.0
│ │ │ ├── boom@0.4.2
│ │ │ ├── cryptiles@0.2.2
│ │ │ ├── hoek@0.9.1
│ │ │ └── sntp@0.2.4
│ │ ├─┬ http-signature@0.10.0
│ │ │ ├── asn1@0.1.11
│ │ │ ├── assert-plus@0.1.2
│ │ │ └── ctype@0.5.2
│ │ ├── json-stringify-safe@5.0.0
│ │ ├── mime@1.2.11
│ │ ├── node-uuid@1.4.1
│ │ ├── oauth-sign@0.3.0
│ │ ├── qs@0.6.6
│ │ ├─┬ tough-cookie@0.12.1
│ │ │ └── punycode@1.2.4
│ │ └── tunnel-agent@0.3.0
│ ├─┬ request-progress@0.3.1
│ │ └── throttleit@0.0.2
│ ├── retry@0.6.0
│ ├── rimraf@2.2.6
│ ├── semver@2.2.1
│ ├─┬ shell-quote@1.4.1
│ │ ├── array-filter@0.0.1
│ │ ├── array-map@0.0.0
│ │ ├── array-reduce@0.0.0
│ │ └── jsonify@0.0.0
│ ├── stringify-object@0.2.0
│ ├─┬ tar@0.1.19
│ │ ├── block-stream@0.0.7
│ │ └── inherits@2.0.1
│ ├── tmp@0.0.23
│ ├─┬ update-notifier@0.1.8
│ │ ├─┬ configstore@0.2.3
│ │ │ ├─┬ js-yaml@3.0.2
│ │ │ │ ├─┬ argparse@0.1.15
│ │ │ │ │ ├── underscore@1.4.4
│ │ │ │ │ └── underscore.string@2.3.3
│ │ │ │ └── esprima@1.0.4
│ │ │ ├── object-assign@0.1.2
│ │ │ └── uuid@1.4.1
│ │ ├─┬ request@2.27.0
│ │ │ ├── aws-sign@0.3.0
│ │ │ ├── cookie-jar@0.3.0
│ │ │ ├── forever-agent@0.5.2
│ │ │ ├─┬ form-data@0.1.2
│ │ │ │ ├── async@0.2.10
│ │ │ │ └─┬ combined-stream@0.0.4
│ │ │ │   └── delayed-stream@0.0.5
│ │ │ ├─┬ hawk@1.0.0
│ │ │ │ ├── boom@0.4.2
│ │ │ │ ├── cryptiles@0.2.2
│ │ │ │ ├── hoek@0.9.1
│ │ │ │ └── sntp@0.2.4
│ │ │ ├─┬ http-signature@0.10.0
│ │ │ │ ├── asn1@0.1.11
│ │ │ │ ├── assert-plus@0.1.2
│ │ │ │ └── ctype@0.5.2
│ │ │ ├── json-stringify-safe@5.0.0
│ │ │ ├── mime@1.2.11
│ │ │ ├── node-uuid@1.4.1
│ │ │ ├── oauth-sign@0.3.0
│ │ │ ├── qs@0.6.6
│ │ │ └── tunnel-agent@0.3.0
│ │ └── semver@2.1.0
│ └── which@1.0.5
├─┬ express@3.2.5
│ ├── buffer-crc32@0.2.1
│ ├── commander@0.6.1
│ ├─┬ connect@2.7.10
│ │ ├── bytes@0.2.0
│ │ ├── cookie@0.0.5
│ │ ├── formidable@1.0.14
│ │ ├── pause@0.0.1
│ │ └── qs@0.6.5
│ ├── cookie@0.1.0
│ ├── cookie-signature@1.0.1
│ ├─┬ debug@1.0.4
│ │ └── ms@0.6.2
│ ├── fresh@0.1.0
│ ├── methods@0.0.1
│ ├── mkdirp@0.3.4
│ ├── range-parser@0.0.4
│ └─┬ send@0.1.0
│   └── mime@1.2.6
├─┬ express-generator@4.2.0
│ ├─┬ commander@1.3.2
│ │ └── keypress@0.1.0
│ └── mkdirp@0.3.5
├─┬ generator-angular@0.8.0
│ ├─┬ chalk@0.4.0
│ │ ├── ansi-styles@1.0.0
│ │ ├── has-color@0.1.7
│ │ └── strip-ansi@0.1.1
│ ├─┬ wiredep@1.0.0
│ │ ├─┬ chalk@0.1.1
│ │ │ ├── ansi-styles@0.1.2
│ │ │ └── has-color@0.1.7
│ │ ├─┬ glob@3.2.11
│ │ │ ├── inherits@2.0.1
│ │ │ └─┬ minimatch@0.3.0
│ │ │   ├── lru-cache@2.5.0
│ │ │   └── sigmund@1.0.0
│ │ └── lodash@1.3.1
│ └─┬ yeoman-generator@0.16.0
│   ├── async@0.2.10
│   ├─┬ cheerio@0.13.1
│   │ ├─┬ CSSselect@0.4.1
│   │ │ ├── CSSwhat@0.4.7
│   │ │ └─┬ domutils@1.4.3
│   │ │   └── domelementtype@1.1.1
│   │ ├── entities@0.5.0
│   │ ├─┬ htmlparser2@3.4.0
│   │ │ ├── domelementtype@1.1.1
│   │ │ ├── domhandler@2.2.0
│   │ │ ├── domutils@1.3.0
│   │ │ └─┬ readable-stream@1.1.13-1
│   │ │   ├── core-util-is@1.0.1
│   │ │   ├── inherits@2.0.1
│   │ │   ├── isarray@0.0.1
│   │ │   └── string_decoder@0.10.25-1
│   │ └── underscore@1.5.2
│   ├── class-extend@0.1.1
│   ├── dargs@0.1.0
│   ├── debug@0.7.4
│   ├── diff@1.0.8
│   ├─┬ download@0.1.17
│   │ ├─┬ decompress@0.2.3
│   │ │ ├── adm-zip@0.4.4
│   │ │ ├─┬ extname@0.1.2
│   │ │ │ └── ext-list@0.1.0
│   │ │ ├── map-key@0.1.4
│   │ │ ├─┬ stream-combiner@0.0.4
│   │ │ │ └── duplexer@0.1.1
│   │ │ ├─┬ tar@0.1.19
│   │ │ │ ├── block-stream@0.0.7
│   │ │ │ ├─┬ fstream@0.1.25
│   │ │ │ │ └── graceful-fs@2.0.3
│   │ │ │ └── inherits@2.0.1
│   │ │ └─┬ tempfile@0.1.3
│   │ │   └── uuid@1.4.1
│   │ ├── each-async@0.1.3
│   │ ├── get-stdin@0.1.0
│   │ ├── get-urls@0.1.2
│   │ ├─┬ nopt@2.2.1
│   │ │ └── abbrev@1.0.5
│   │ ├─┬ request@2.36.0
│   │ │ ├── aws-sign2@0.5.0
│   │ │ ├── forever-agent@0.5.2
│   │ │ ├─┬ form-data@0.1.2
│   │ │ │ └─┬ combined-stream@0.0.4
│   │ │ │   └── delayed-stream@0.0.5
│   │ │ ├─┬ hawk@1.0.0
│   │ │ │ ├── boom@0.4.2
│   │ │ │ ├── cryptiles@0.2.2
│   │ │ │ ├── hoek@0.9.1
│   │ │ │ └── sntp@0.2.4
│   │ │ ├─┬ http-signature@0.10.0
│   │ │ │ ├── asn1@0.1.11
│   │ │ │ ├── assert-plus@0.1.2
│   │ │ │ └── ctype@0.5.2
│   │ │ ├── json-stringify-safe@5.0.0
│   │ │ ├── node-uuid@1.4.1
│   │ │ ├── oauth-sign@0.3.0
│   │ │ ├── qs@0.6.6
│   │ │ ├─┬ tough-cookie@0.12.1
│   │ │ │ └── punycode@1.2.4
│   │ │ └── tunnel-agent@0.4.0
│   │ └─┬ through2@0.4.2
│   │   ├─┬ readable-stream@1.0.27-1
│   │   │ ├── core-util-is@1.0.1
│   │   │ ├── inherits@2.0.1
│   │   │ ├── isarray@0.0.1
│   │   │ └── string_decoder@0.10.25-1
│   │   └─┬ xtend@2.1.2
│   │     └── object-keys@0.4.0
│   ├─┬ file-utils@0.1.5
│   │ ├── isbinaryfile@0.1.9
│   │ ├── lodash@2.1.0
│   │ └─┬ minimatch@0.2.14
│   │   ├── lru-cache@2.5.0
│   │   └── sigmund@1.0.0
│   ├── findup-sync@0.1.3
│   ├─┬ glob@3.2.11
│   │ ├── inherits@2.0.1
│   │ └─┬ minimatch@0.3.0
│   │   ├── lru-cache@2.5.0
│   │   └── sigmund@1.0.0
│   ├── iconv-lite@0.2.11
│   ├─┬ inquirer@0.4.1
│   │ ├─┬ cli-color@0.2.3
│   │ │ ├── es5-ext@0.9.2
│   │ │ └─┬ memoizee@0.2.6
│   │ │   ├── event-emitter@0.2.2
│   │ │   └── next-tick@0.1.0
│   │ ├── mute-stream@0.0.4
│   │ ├── readline2@0.1.0
│   │ └── through@2.3.4
│   ├── isbinaryfile@2.0.1
│   ├── lodash@2.4.1
│   ├── mime@1.2.11
│   ├── mkdirp@0.3.5
│   ├─┬ request@2.30.0
│   │ ├── aws-sign2@0.5.0
│   │ ├── forever-agent@0.5.2
│   │ ├─┬ form-data@0.1.2
│   │ │ └─┬ combined-stream@0.0.4
│   │ │   └── delayed-stream@0.0.5
│   │ ├─┬ hawk@1.0.0
│   │ │ ├── boom@0.4.2
│   │ │ ├── cryptiles@0.2.2
│   │ │ ├── hoek@0.9.1
│   │ │ └── sntp@0.2.4
│   │ ├─┬ http-signature@0.10.0
│   │ │ ├── asn1@0.1.11
│   │ │ ├── assert-plus@0.1.2
│   │ │ └── ctype@0.5.2
│   │ ├── json-stringify-safe@5.0.0
│   │ ├── node-uuid@1.4.1
│   │ ├── oauth-sign@0.3.0
│   │ ├── qs@0.6.6
│   │ ├─┬ tough-cookie@0.9.15
│   │ │ └── punycode@1.2.4
│   │ └── tunnel-agent@0.3.0
│   ├── rimraf@2.2.8
│   ├── shelljs@0.2.6
│   ├── text-table@0.2.0
│   └── underscore.string@2.3.3
├─┬ generator-angular-fullstack@1.4.2
│ ├─┬ chalk@0.4.0
│ │ ├── ansi-styles@1.0.0
│ │ ├── has-color@0.1.7
│ │ └── strip-ansi@0.1.1
│ ├─┬ wiredep@0.4.2
│ │ ├─┬ chalk@0.1.1
│ │ │ ├── ansi-styles@0.1.2
│ │ │ └── has-color@0.1.7
│ │ └── lodash@1.3.1
│ └─┬ yeoman-generator@0.16.0
│   ├── async@0.2.10
│   ├─┬ cheerio@0.13.1
│   │ ├─┬ CSSselect@0.4.1
│   │ │ ├── CSSwhat@0.4.5
│   │ │ └─┬ domutils@1.4.3
│   │ │   └── domelementtype@1.1.1
│   │ ├── entities@0.5.0
│   │ ├─┬ htmlparser2@3.4.0
│   │ │ ├── domelementtype@1.1.1
│   │ │ ├── domhandler@2.2.0
│   │ │ ├── domutils@1.3.0
│   │ │ └─┬ readable-stream@1.1.13-1
│   │ │   ├── core-util-is@1.0.1
│   │ │   ├── inherits@2.0.1
│   │ │   ├── isarray@0.0.1
│   │ │   └── string_decoder@0.10.25-1
│   │ └── underscore@1.5.2
│   ├── class-extend@0.1.1
│   ├── dargs@0.1.0
│   ├── debug@0.7.4
│   ├── diff@1.0.8
│   ├─┬ download@0.1.16
│   │ ├─┬ decompress@0.2.3
│   │ │ ├── adm-zip@0.4.4
│   │ │ ├─┬ extname@0.1.2
│   │ │ │ └── ext-list@0.1.0
│   │ │ ├─┬ map-key@0.1.1
│   │ │ │ └── mout@0.9.1
│   │ │ ├─┬ stream-combiner@0.0.4
│   │ │ │ └── duplexer@0.1.1
│   │ │ ├─┬ tar@0.1.19
│   │ │ │ ├── block-stream@0.0.7
│   │ │ │ ├─┬ fstream@0.1.25
│   │ │ │ │ └── graceful-fs@2.0.3
│   │ │ │ └── inherits@2.0.1
│   │ │ └─┬ tempfile@0.1.3
│   │ │   └── uuid@1.4.1
│   │ ├── each-async@0.1.2
│   │ ├── get-stdin@0.1.0
│   │ ├── get-urls@0.1.1
│   │ ├─┬ nopt@2.2.0
│   │ │ └── abbrev@1.0.5
│   │ ├─┬ request@2.34.0
│   │ │ ├── aws-sign2@0.5.0
│   │ │ ├── forever-agent@0.5.2
│   │ │ ├─┬ form-data@0.1.2
│   │ │ │ └─┬ combined-stream@0.0.4
│   │ │ │   └── delayed-stream@0.0.5
│   │ │ ├─┬ hawk@1.0.0
│   │ │ │ ├── boom@0.4.2
│   │ │ │ ├── cryptiles@0.2.2
│   │ │ │ ├── hoek@0.9.1
│   │ │ │ └── sntp@0.2.4
│   │ │ ├─┬ http-signature@0.10.0
│   │ │ │ ├── asn1@0.1.11
│   │ │ │ ├── assert-plus@0.1.2
│   │ │ │ └── ctype@0.5.2
│   │ │ ├── json-stringify-safe@5.0.0
│   │ │ ├── node-uuid@1.4.1
│   │ │ ├── oauth-sign@0.3.0
│   │ │ ├── qs@0.6.6
│   │ │ ├─┬ tough-cookie@0.12.1
│   │ │ │ └── punycode@1.2.4
│   │ │ └── tunnel-agent@0.3.0
│   │ └─┬ through2@0.4.1
│   │   ├─┬ readable-stream@1.0.27-1
│   │   │ ├── core-util-is@1.0.1
│   │   │ ├── inherits@2.0.1
│   │   │ ├── isarray@0.0.1
│   │   │ └── string_decoder@0.10.25-1
│   │   └─┬ xtend@2.1.2
│   │     └── object-keys@0.4.0
│   ├─┬ file-utils@0.1.5
│   │ ├── isbinaryfile@0.1.9
│   │ ├── lodash@2.1.0
│   │ └─┬ minimatch@0.2.14
│   │   ├── lru-cache@2.5.0
│   │   └── sigmund@1.0.0
│   ├── findup-sync@0.1.3
│   ├─┬ glob@3.2.9
│   │ ├── inherits@2.0.1
│   │ └─┬ minimatch@0.2.14
│   │   ├── lru-cache@2.5.0
│   │   └── sigmund@1.0.0
│   ├── iconv-lite@0.2.11
│   ├─┬ inquirer@0.4.1
│   │ ├─┬ cli-color@0.2.3
│   │ │ ├── es5-ext@0.9.2
│   │ │ └─┬ memoizee@0.2.6
│   │ │   ├── event-emitter@0.2.2
│   │ │   └── next-tick@0.1.0
│   │ ├── mute-stream@0.0.4
│   │ ├── readline2@0.1.0
│   │ └── through@2.3.4
│   ├── isbinaryfile@2.0.1
│   ├── lodash@2.4.1
│   ├── mime@1.2.11
│   ├── mkdirp@0.3.5

...

实际上无法全部发布 - 这个问题已经很长了,哈哈。

所以我想我可以仔细检查并确保所有这些都是相同的......但是有人知道哪些对于我遇到的问题最重要吗?

吉普斯,这会很烦人!

最佳答案

这几天我一直致力于让我的网站在 openshift 上运行。我花了一两天时间确保我在计算机上使用的所有 npm 软件包版本与 openshift 上使用的版本相同。同步所有版本后,重构我的代码需要做很多工作,但我最终让它工作起来。

我必须弄清楚的主要错误是,当我尝试执行 PUT 请求时,即使我认为我没有更改 _id 字段 - 它也会给我这个错误:

MongoError: Mod on _id not allowed

我最终意识到我需要创建一个具有所有相同信息的对象,只是没有 _id 字段才能使更新生效。

除此之外,只是需要进行大量修改才能使其正确 - 这是我的劳动成果 - http://hackabox-eamonbenproject.rhcloud.com/ - 我遇到的问题与我正在创建的论坛有关,因此请检查一下 - 它功能齐全。

关于javascript - 在 Openshift 上运行 MEAN 站点时出现非常奇怪的 Mongoose/MongoDB 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24847384/

相关文章:

javascript - 如何将base64与src中的类型连接

javascript退出for循环而不返回

mysql - Sequelizejs 中的 .save 和 .create 有什么区别?

mysql - 从索引表中高效查询

javascript - 计算旋转度数的问题

php - 从 AJAX 动态加载 JavaScript - 失败?

具有 Socket.io 客户端支持的 Node.js 托管?

node.js - 如何使用 xPath 在 Puppeteer 中单击元素

mongodb - Mongoose/MongoDB - 保存记录以覆盖当前数据 :

javascript - mongoose - 使用 $pull 删除数组中的元素