【问题标题】:Module.js failed to load server.jsModule.js 无法加载 server.js
【发布时间】:2016-11-30 04:51:40
【问题描述】:

我使用 node.js 做了一个小项目,用 Discord 做一些事情。当我使用 node server.jsnpm start 在本地运行它时,它起作用了。我决定将我的项目放到网上,看看某个功能是否有效。当我上传它时,没有找到启动所有内容的主要 javascript 文件 (server.js)。

I just want to be clear that Module.js is not something I made, but part of the node.js built in modules. It's the thing that makes the require function what it is.

错误至极:

module.js:472
    throw err;
    ^
Error: Cannot find module '/var/lib/openshift/583e028e2d52714d2500041/approot/runtime/repo/server.js'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:420:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:535:3

Package.json:

{
  "name": "app",
  "version": "0.0.1",
  "description": "test",
  "scripts": { 
    "start": "node --use_strict server.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "main": "server.js",
  "keywords": [
    "discord",
  ],
  "author": "kert",
  "license": "ISC",
  "dependencies": {
    "express": "^4.14.0",
    "discord.js": "7.0.0"
  },
  "engines" : {
    "node" : "6.9.1"
  }
} 

文件结构:

Discord
└─── .git
└─── node_modules
└─── rbservers <-nothing is used in this folder
└─── app.js
└─── package.json
└─── server.js

如果有人能指出我忘记了什么愚蠢的事情,请告诉我。

我在 OpenShift 上的墨盒是“Node.js 自动更新”墨盒。

【问题讨论】:

  • 您是否使用 npm install 命令安装了所有必需的依赖项?
  • 您检查过文件夹的权限吗?并安装了所有包
  • @AJS 是的。我在我的 node_modules 文件夹中找到了这两个依赖项。
  • @ManishSingh 可以肯定的是,我只是重新运行该命令并发布到 OpenShift。没有任何改变。
  • 你能显示module.js代码吗?究竟在哪一行你得到了错误。还有你如何包含 server.js

标签: javascript node.js openshift


【解决方案1】:

显然,git 并没有暂存/提交所有文件以便推送它们。我将不得不四处看看如何解决这个问题。

呃。

【讨论】:

  • git add *修复
猜你喜欢
  • 1970-01-01
  • 2017-05-18
  • 1970-01-01
  • 2022-11-09
  • 2019-05-25
  • 2015-10-08
  • 2022-12-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多