简体   繁体   English

Openshift部署错误:找不到模块package.json

[英]Openshift deploy error: Cannot find module package.json

I'm trying to decrease the size of my openshift backend node app by using webpack to bundle my node file first, and then just push that. 我试图通过使用webpack首先捆绑我的节点文件,然后将其推送来减小我的openshift后端节点应用程序的大小。 Here is the error I'm getting: 这是我得到的错误:

Total 642 (delta 200), reused 2 (delta 0)
remote: module.js:471
remote:     throw err;
remote:     ^
remote: 
remote: Error: Cannot find module '/var/lib/openshift/575efb722d5271dec00000f4/app-root/runtime/repo//package.json'
remote:     at Function.Module._resolveFilename (module.js:469:15)
remote:     at Function.Module._load (module.js:417:25)
remote:     at Module.require (module.js:497:17)
remote:     at require (internal/module.js:20:19)
remote:     at [eval]:1:9
remote:     at ContextifyScript.Script.runInThisContext (vm.js:25:33)
remote:     at Object.runInThisContext (vm.js:97:38)
remote:     at Object.<anonymous> ([eval]-wrapper:6:22)
remote:     at Module._compile (module.js:570:32)
remote:     at evalScript (bootstrap_node.js:353:27)
remote: CLIENT_MESSAGE: Stopping Node.js application...
Connection to api-tmarr.rhcloud.com closed by remote host.
fatal: The remote end hung up unexpectedly

Here is my webpack config file: 这是我的webpack配置文件:

var webpack = require('webpack');
var path = require('path');
var fs = require('fs');

var nodeModules = {};
fs.readdirSync('node_modules')
  .filter(function(x) {
    return ['.bin'].indexOf(x) === -1;
  })
  .forEach(function(mod) {
    nodeModules[mod] = 'commonjs ' + mod;
  });

module.exports = {
  entry: './src/app.js',
  target: 'node',
  output: {
    path: path.join(__dirname, 'build'),
    filename: 'backend.js'
  },
  externals: nodeModules,
  plugins: [
    new webpack.IgnorePlugin(/\.(css|less)$/),

    new webpack.BannerPlugin({banner: 'require("source-map-support").install();', raw: true, entryOnly: false})
  ],
  devtool: 'sourcemap'
}

which creates a backend.js file, which is then copied to a skeleton project which just has the bare minimum in it and is hooked up to openshift with git. 会创建一个backend.js文件,然后将其复制到一个骨架项目中,该项目中的裸机最少,并使用git连接到openshift。 This new skeleton project has its own package.json & start.js file. 这个新的骨架项目具有自己的package.json和start.js文件。

package.json: 的package.json:

{
  "name": "API",
  "version": "1.0.1",
  "description": "Terry's API Server",
  "private": true,
  "main": "start.js",
  "scripts": {
    "prestart": "NODE_ENV=production",
    "start": "node --use_strict start.js --websocket-port=$OPENSHIFT_NODEJS_PORT --log-level=1"
  },
  "author": "Terry Marr",
  "license": "ISC",
  "dependencies": {
    "cors": "^2.8.1",
    "express": "~3.4.4",
    "express-cache-ctrl": "^1.0.1"
  },

  "engines": {
    "node": ">= 0.6.0",
    "npm": ">= 1.0.0"
  },
  "devDependencies": {}
}

Here is the resulting skeletal structure: 这是生成的骨骼结构:

/build
  -backend.js
  -backend.js.map
/node_modules ...
/static ...
/utils ...
-.gitignore
-package.json
-start.js

It might be important that what I'm trying to do is REDO my app. 我想做的是重做我的应用程序可能很重要。 It was working before without webpack. 以前没有webpack的情况下就可以正常工作。 Maybe there's something up there from the old code? 也许旧代码有什么用? Rather new to Openshift, and find the docs not very helpful. 并不是Openshift的新手,并且发现文档不是很有帮助。 Should I clear out my code there and repush? 我应该在那里清除我的代码并重新推送吗? Not sure how to do that. 不知道该怎么做。 Appreciative of any help. 感谢任何帮助。

UPDATE: Nobody answered my question, and Openshift's support really bites. 更新:没有人回答我的问题,Openshift的支持确实令人难忘。 Their documentation sucks and there is absolutely noone to help when you're stuck. 他们的文档很烂,当您陷入困境时,绝对没有人可以提供帮助。 I'm pulling my (paid) app and moving over to Heroku. 我正在拉我的(付费)应用程序,然后转到Heroku。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:找不到模块“../../package.json” - Error: Cannot find module '../../package.json' 尝试将 Vue App 部署到 Azure App Service,导致错误:找不到模块 '../package.json' - Trying to deploy Vue App to Azure App Service, results in Error: Cannot find module '../package.json' 电子找不到模块 package.json - electron cannot find module package.json Electron 带 Strapi,找不到模块 package.json - Electron with strapi, Cannot find module package.json 错误:即使在 package.json 中列出,也找不到模块“ejs” - Error: Cannot find module 'ejs' even though it's listed in package.json Google Cloud Functions 错误:“找不到模块‘sharp’”,但它在我的 package.json 中 - Google Cloud Functions error: "Cannot find module 'sharp'" but it's in my package.json 错误:找不到模块'@angular-devkit/build-angular/package.json' - Error: Cannot find module '@angular-devkit/build-angular/package.json' 错误:找不到模块 'node-linux-x64/package.json' - 第一次推送到 Heroku - Error: Cannot find module 'node-linux-x64/package.json' - pushing to Heroku for first time 推送到Heroku时出错:找不到模块“ node-linux-x64 / package.json” - Error while pushing to Heroku: Cannot find module 'node-linux-x64/package.json' 错误:找不到模块请验证 package.json 在 npm 上运行开发时存在有效的“主”条目 nuxtjs 错误 - Error: Cannot find module Please verify that the package.json has a valid "main" entry nuxtjs error on npm run dev
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM