【问题标题】:Node app is not running on my PC but running fine with other PC of my team (using Git)Node 应用程序未在我的 PC 上运行,但在我团队的其他 PC 上运行良好(使用 Git)
【发布时间】:2017-01-06 00:23:54
【问题描述】:

我们的团队使用 Node.js 服务器制作了一个项目,并使用 GitHub 作为源代码控制。问题是我什么时候运行服务器。我使用后续步骤来测试 master 是否会启动应用程序。

git checkout master
git pull
npm update
node .\backend\server.js

最后一条评论给了我下一个错误。

D:\***\node_modules\passport-oauth2\lib\strategy.js:82
  if (!options.clientID) { throw new TypeError('OAuth2Strategy requires a clientID option'); }
                           ^

TypeError: OAuth2Strategy requires a clientID option
    at Strategy.OAuth2Strategy (D:\Documenten\WatchFriends\Web\node_modules\passport-oauth2\lib\strategy.js:82:34)
    at new Strategy (D:\Documenten\WatchFriends\Web\node_modules\passport-google-oauth20\lib\strategy.js:52:18)
    at module.exports.config (D:\Documenten\WatchFriends\Web\backend\data\passport.js:94:18)
    at Object.<anonymous> (D:\Documenten\WatchFriends\Web\backend\server.js:16:1)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3

其他团队合作伙伴也在同一个存储库上工作,他们已经完成了相同的步骤来测试 master 是否会运行。奇怪的问题是他们没有任何问题。被.gitignore文件忽略的配置文件也是相等的。

问题:代码不能在我的电脑上运行而在其他电脑上运行的问题是什么?

我已尝试从 GitHub 删除并重新克隆项目,重新安装节点模块并添加被忽略的文件。但这并不能解决错误。我正在使用节点版本 6.9.3 和 git 版本 2.10.2.windows.1。

更新:

  • 这里是我们的 GitHub 项目的链接:github.com/WatchFriends/Web
  • 这是 Travis 的构建状态(只是检查一些 gulp 任务,还有 npm run build
  • 这里是 Travis 的链接:travis-ci.org/WatchFriends/Web
  • Travis的配置:./.travis.yml on GitHub

    install:
      - npm install
      - npm install -g angular-cli
    language: node_js
    script:
      - gulp html
      - gulp scss
      - gulp ts
      - gulp node
    node_js:
      - "6.9"
    cache:
      directories:
        - node_modules
        - bower_components
    

【问题讨论】:

  • 您应该比较您的 PC 和团队成员 PC 上的环境变量
  • 它显然缺少一些东西,也许有一个配置文件夹或文件,你必须先设置一些东西? strategy.js 第 82 行发生了什么?

标签: node.js git npm travis-ci


【解决方案1】:

这就是为什么您应该使用 Travis、Circle 或 Codeship 等持续集成系统在干净的系统上运行测试 - 以避免应用程序无法运行但有人说“它在我的系统上运行”的情况。

显然,您的系统必须在某些方面与代码运行的系统有所不同。您可以安装不同的软件、运行不同的服务、不同的库、不同的环境变量、不同的操作系统,或者您可能在安装或启动应用程序期间执行了不同的操作。

开始使用 CI,您会立即发现问题所在。

也可以使用 npm 来启动你的服务:

npm start

这样你就知道你和其他人正在运行相同的命令。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2020-03-05
  • 2014-03-02
  • 2017-12-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多