在openshift上自定义node.js的版本
https://github.com/ramr/nodejs-custom-version-openshift
由于是线上服务器,一步一步来:
先把上面的工程拉下来,覆盖到初始化的工程里,提交,让服务器端装起来。
# Uncomment one of the version lines to select the node version to use. # The last "non-blank" version line is the one picked up by the code in # .openshift/lib/utils # Default: 0.10.25 # # 0.8.24 # 0.9.1 # 0.10.25 # 0.11.11 # 0.12.2 # 0.12.5 4.2.3
配置好.openshift/markers/NODEJS_VERSION (默认写的4.2.3, 我改的6.9.2)
如果失败了,找到最初commit id 用reset --hard HEAD~1 一版一版往前退,
然后pull 返回去初始状态,否则错上推错很有可能会出现被服务器永久拒绝的状态(哭),那就只能重新建应用了
还没commit的直接 checkout --force 就放弃修改了
一堆无关痛痒的依赖错误之后是:
那么会不会是503呢,它没有明显的deploy failure,说是node启动失败
看看dashboard 状态
只要不是一直被stopped就还有希望
页面并没有受到影响,仍然显示默认的index.html
在dashboard点restart,重启之后页面仍然正常显示,猜想服务器终于把node给升级好啦?
(尝试了一次不点restrt, 跑去网上冲浪不知等了多久也自动能stated) 页面改头换面了:
把package.json里面scripts、dependencies、devDependencies加进去
再次push应该会看到这样
明显的node已经升级成功,但是dashboard上仍然显示0.10
然后我有一个用了webpack的工程需要移植上去,
根据stackoverflow这篇文章,需要设置.openshift中的action_hook下build文件:
create the following file: .openshift/action_hook/build
which contains the following:
#!/bin/bash
webpack --config $OPENSHIFT_DATA_DIR/webpack.config.js
题主出现了报错,但我是一次成功的。。。
另外,如果出现这种问题像我之前查到的解决方式一样需要配置静态地址:
self.initializeServer = function() {self.createRoutes();self.app = express();self.app.use('/', express.static(__dirname + '/dist'));// Add handlers for the app (from the routes).for (var r in self.routes) {self.app.get(r, self.routes[r]);}};
还有上面一段populate the cache也需要设置
/*** Populate the cache.*/self.populateCache = function() {if (typeof self.zcache === "undefined") {self.zcache = { 'index.html': '' };}// Local cache for static content.//原来openshift给的index.html//self.zcache['index.html'] = fs.readFileSync('./index.html');self.zcache['index.html'] = fs.readFileSync('./dist/index.html');};
这样就和本地启动一样了,本地npm start还是可以指定其他的入口文件进行本地启动,并不会冲突。
$ git push Counting objects: 35, done. Delta compression using up to 4 threads. Compressing objects: 100% (35/35), done. Writing objects: 100% (35/35), 43.95 KiB | 0 bytes/s, done. Total 35 (delta 13), reused 0 (delta 0) remote: remote: - pre_stop_nodejs: Adding Node.js version 6.9.2 binaries to path remote: - PATH set to include custom node version (6.9.2) from remote: /var/lib/openshift/585cd49089f5cf3e75000095/app-root/data//node-v6.9.2-linux-x64/bin remote: PATH = /var/lib/openshift/585cd49089f5cf3e75000095/app-root/data//node-v6.9.2-linux-x64/bin:/var/lib/openshift/585cd49089f5cf3e75000095/app-root/runtime/repo/node_modules/.bin:/var/lib/openshift/585cd49089f5cf3e75000095//.node_modules/.bin:/opt/rh/nodejs010/root/usr/bin:/bin:/usr/bin:/usr/sbin remote: Stopping NodeJS cartridge remote: Tue Dec 27 2016 03:15:41 GMT-0500 (EST): Stopping application 'angular' ... remote: Tue Dec 27 2016 03:15:42 GMT-0500 (EST): Stopped Node application 'angular' remote: Repairing links for 1 deployments remote: Saving away previously installed Node modules remote: Building git ref 'master', commit d3e7fb0 remote: NOTE: The .openshift/action_hooks/pre_build hook is not executable, to make it executable: remote: On Windows run: git update-index --chmod=+x .openshift/action_hooks/pre_build remote: On Linux/OSX run: chmod +x .openshift/action_hooks/pre_build remote: Building NodeJS cartridge remote: npm info it worked if it ends with ok remote: npm info using npm@2.14.13 remote: npm info using node@v0.10.35 remote: npm info preinstall nodejs-Custom-Version-Sample@1.0.1 remote: npm info package.json core-js@2.4.1 No README data remote: npm info package.json ts-loader@0.8.2 No README data remote: npm info package.json @angular/compiler@2.0.0-rc.6 No README data remote: npm info package.json @angular/common@2.0.0-rc.6 No description remote: npm info package.json @angular/common@2.0.0-rc.6 No README data remote: npm info package.json @angular/compiler-cli@0.6.0 No README data remote: npm info package.json @angular/core@2.0.0-rc.6 No README data remote: npm info package.json @angular/forms@2.0.0-rc.6 No README data remote: npm info package.json @angular/http@2.0.0-rc.6 No README data remote: npm info package.json @angular/platform-browser@2.0.0-rc.6 No README data remote: npm info package.json @angular/platform-browser-dynamic@2.0.0-rc.6 No README data remote: npm info package.json @angular/router@3.0.0-rc.2 No README data remote: npm info package.json @angular/upgrade@2.0.0-rc.6 No description remote: npm info package.json @angular/upgrade@2.0.0-rc.6 No README data remote: npm info package.json echarts@3.3.2 No license field. remote: npm info package.json raw-loader@0.5.1 No license field. remote: npm info build /var/lib/openshift/585cd49089f5cf3e75000095/app-root/runtime/repo remote: npm info linkStuff nodejs-Custom-Version-Sample@1.0.1 remote: npm info install nodejs-Custom-Version-Sample@1.0.1 remote: npm info postinstall nodejs-Custom-Version-Sample@1.0.1 remote: remote: > nodejs-Custom-Version-Sample@1.0.1 postinstall /var/lib/openshift/585cd49089f5cf3e75000095/app-root/runtime/repo remote: > typings install remote: remote: remote: Error: EACCES, permission denied '/var/lib/openshift/585cd49089f5cf3e75000095/.config' remote: at Object.fs.mkdirSync (fs.js:654:18) remote: at sync (/var/lib/openshift/585cd49089f5cf3e75000095/app-root/runtime/repo/node_modules/typings/node_modules/typings-core/node_modules/mkdirp/index.js:71:13) remote: at Function.sync (/var/lib/openshift/585cd49089f5cf3e75000095/app-root/runtime/repo/node_modules/typings/node_modules/typings-core/node_modules/mkdirp/index.js:77:24) remote: at Object.create.all.get (/var/lib/openshift/585cd49089f5cf3e75000095/app-root/runtime/repo/node_modules/typings/node_modules/typings-core/node_modules/configstore/index.js:39:13) remote: at Object.Configstore (/var/lib/openshift/585cd49089f5cf3e75000095/app-root/runtime/repo/node_modules/typings/node_modules/typings-core/node_modules/configstore/index.js:28:44) remote: at Object.<anonymous> (/var/lib/openshift/585cd49089f5cf3e75000095/app-root/runtime/repo/node_modules/typings/node_modules/typings-core/dist/utils/store.js:5:19) remote: at Module._compile (module.js:456:26) remote: at Object.Module._extensions..js (module.js:474:10) remote: at Module.load (module.js:356:32) remote: at Function.Module._load (module.js:312:12) remote: at Module.require (module.js:364:17) remote: at require (module.js:380:17) remote: at Object.<anonymous> (/var/lib/openshift/585cd49089f5cf3e75000095/app-root/runtime/repo/node_modules/typings/node_modules/typings-core/dist/utils/fs.js:29:15) remote: at Module._compile (module.js:456:26) remote: at Object.Module._extensions..js (module.js:474:10) remote: at Module.load (module.js:356:32) remote: remote: npm info nodejs-Custom-Version-Sample@1.0.1 Failed to exec postinstall script remote: npm ERR! Linux 2.6.32-642.6.2.el6.x86_64 remote: npm ERR! argv "node" "/opt/rh/nodejs010/root/usr/bin/npm" "install" "-d remote: npm ERR! node v0.10.35 remote: npm ERR! npm v2.14.13 remote: npm ERR! code ELIFECYCLE remote: npm ERR! nodejs-Custom-Version-Sample@1.0.1 postinstall: `typings install` remote: npm ERR! Exit status 8 remote: npm ERR! remote: npm ERR! Failed at the nodejs-Custom-Version-Sample@1.0.1 postinstall script 'typings install'. remote: npm ERR! This is most likely a problem with the nodejs-Custom-Version-Sample package, remote: npm ERR! not with npm itself. remote: npm ERR! Tell the author that this fails on your system: remote: npm ERR! typings install remote: npm ERR! You can get their info via: remote: npm ERR! npm owner ls nodejs-Custom-Version-Sample remote: npm ERR! There is likely additional logging output above. remote: remote: npm ERR! Please include the following file with any support request: remote: npm ERR! /var/lib/openshift/585cd49089f5cf3e75000095/app-root/runtime/repo/npm-debug.log remote: An error occurred executing 'gear postreceive' (exit code: 1) remote: Error message: CLIENT_ERROR: Failed to execute: 'control build' for /var/lib/openshift/585cd49089f5cf3e75000095/nodejs remote: remote: For more details about the problem, try running the command again with the '--trace' option. To ssh://xxx.rhcloud.com/~/git/angular.git/bf853eb..d3e7fb0 master -> master
每次push完也没法直接看到页面,总是会进入building,等它打包完自动started就好了。
转载于:https://www.cnblogs.com/haimingpro/p/6182347.html
在openshift上自定义node.js的版本相关推荐
- (转)在Windows平台上安装Node.js及NPM模块管理
本文转载自:http://www.cnblogs.com/seanlv/archive/2011/11/22/2258716.html 之前9月份的时候我写了一篇关于如何在Windows平台上手工管理 ...
- Node.js 体验-在Windows Azure工作者角色上托管Node.js
在我的前面的文章中我演示了如何在Windows Azure 网站(即WAWS)上开发和部署Node.js 应用程序.WAWS是Windows Azure 平台中的新功能.因为它是低成本, 同时它提供I ...
- 在 Ubuntu 14.04/15.04 上配置 Node JS v4.0.0
大家好,Node.JS 4.0 发布了,这个流行的服务器端 JS 平台合并了 Node.js 和 io.js 的代码,4.0 版就是这两个项目结合的产物--现在合并为一个代码库.这次最主要的变化是 N ...
- 在Visual Studio上开发Node.js程序
在Visual Studio上开发Node.js程序 原文:在Visual Studio上开发Node.js程序 [题外话] 最近准备用Node.js做些东西,于是找找看能否有Visual Studi ...
- Node.js 多版本安装配置(Window、Ubuntu 、CentOS 、Mac OS、Cloud Studio)
前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. 向大家介绍在window和Linux上安装Node.js的方法. 本安装教程以Node.js v4. ...
- 如何在Mac上安装Node.js和NPM
原作者:Dave McFarland 翻译转载:https://blog.teamtreehouse.com/install-node-js-npm-mac 如何在Mac上安装Node.js和NPM ...
- 如何在Docker上构建Node.js应用程序
Docker has been the latest trending topic over the past couple of years and if you haven't been to s ...
- 在CentOS 7上安装Node.js的4种方法(yum安装和源码安装)
CentOS 7上的安装方法,其中涵盖了源码安装,已编译版本安装,EPEL(Extra Packages for Enterprise Linux)安装和通过NVM(Node version mana ...
- linux安装nodejs 7,在CentOS 7上安装Node.js的4种方法
Node.js和Javascript有着千丝万缕的联系,可以说Node.js让Javascript显得从未如此强大.好吧-微魔其实是个门外汉-但是这并不能阻碍微魔学习探索未知的信心~今天在国外闲逛,看 ...
最新文章
- Exception in thread main java.lang.NoSuchMethodError: scala.Predef$
- Winform中使用NPOI实现导出Excel并文件另存为
- centos查看网关地址
- Hadoop Yarn容量调度器特点和分配算法介绍
- c#sql防注入模糊查询_SQL中利用LIKE实现模糊查询的功能
- 取得数组下标_《零基础C++入门教程》——(8)搞定二维数组与循环嵌套
- Linux 常用命令整理
- IIS 7.5出现500.19错误解决方法
- 上传相关js和jquery对象
- 深度学习与人类语言处理-语音识别(part1)
- Linux DRM 理解
- android 系统GPS模块
- 能否在计算机界面保存快捷方式,详细教您清理1kb快捷方式病毒
- Maven与Eclipse的整合和简单的Maven项目(二)
- Lync Server 2013 标准版的DNS和端口要求
- android 单元布局,在Android布局中挖洞
- 卷积神经网络CNN简图
- 苹果手机不和安卓手机比堆料的原因
- 在vue新版脚手架中下载和使用jquery
- 真实机下 ubuntu 18.04 安装anaconda+cuDNN+pytorch以及其版本选择(亲测非常实用)
热门文章
- 【数据库】索引优化策略
- php的VC9-VC14运行库分享以及localhost访问404问题
- php批量生成产品编号:xxx.000001,并依次递增
- 【深度学习】如何从结构出发更好的改进一个神经网络(二)
- 【Java Web开发指南】Maven+MyBatis实现增删改查的Demo
- python基础练习(二)
- 线程同步锁 java_java多线程同步之重入锁,详细解析
- skywalking es7_SpringCloud下skywalking的快速入门
- 本地代码替换到某个提交点_github教程 -- Windows平台下如何将项目华丽的提交到Github上...
- Android 请求PHP接口, 返回json, 开头有问号, 解决方案