繁体   English   中英

open.hift node.js项目的npm安装错误

[英]npm install error for openshift node.js project

在browserify 4.0.0上部署带有depdency的OpenShift node.js项目时,我在安装browserify的依赖项时出错。 特别:

...
remote: npm ERR! Error: No compatible version found: stream-browserify@'^1.0.0'
remote: npm ERR! Valid install targets:
remote: npm ERR! ["0.0.0","0.0.1","0.0.2","0.0.3","0.0.4","0.1.0","0.1.1","0.1.2","0.1.3","1.0.0"]
...

鉴于browser-browserify的版本是^ 1.0.0,根据browserify的depdency,openshift建议1.0.0是一个有效的安装目标,为什么这会失败? 在其他情况下,只要最高可用的openshift版本符合careted package.json版本,我就会看到此错误。

我误解了插入符号的含义吗? 这是一个OpenShift错误吗?

我的package.json:

{
  "name": "SampleApp",
  "version": "1.0.0",
  "description": "do things online",
  "keywords": [
    "OpenShift",
    "Node.js",
    "application",
    "openshift"
  ],
  "author": {
    "name": "J",
    "email": "j@email.com",
    "url": ""
  },
  "homepage": "http://www.openshift.com/",
  "repository": {
    "type": "git",
    "url": "https://github.com/openshift/origin-server"
  },
  "engines": {
    "node": "0.x",
    "npm": "1.x"
  },
  "dependencies": {
    "body-parser": "1.x",
    "browserify": "4.0.0",
    "cookie-parser": "1.x",
    "cookie-session": "1.x",
    "express": "4.x",
    "fast-csv": "0.x",
    "multer": "0.0.5",
    "pg": "3.x",
    "sql": "0.x",
    "xlsx-extract": "0.0.4"
  },
  "devDependencies": {
  },
  "bundleDependencies": [],
  "private": true,
  "main": "server.js",
  "scripts": {
    "build-js": "browserify public/index.js -o public/index-bundle.js & browserify public/intake.js -o public/intake-bundle.js",
    "start": "npm run build-js && node server.js"
  }
}

此行为可能是因为节点上的不同版本和本地计算机上的npm以及openshift环境。 首先修改package.json中的“engines”属性,如下所示:

"engines": {
    "node": ">= 0.10",
    "npm": ">= 1.4"
  }

如果仍有问题(在openshift上),那是由于openshift环境中nodejs / npm所需版本不可用。 例如,截至今天,在我的本地机器上,我可能正在使用节点版本0.10.28和npm版本1.4.9,但在openshift nodejs默认盒式磁带上我必须满足于nodejs版本0.10.5和npm版本1.2.17 ,这是一个很大的差距。

因此,在这种情况下,最简单的解决方法是使用“npm shrinkwrap”,它冻结了应该使用的嵌套依赖版本,从而消除了npm版本的各种行为,以找出要安装的嵌套依赖项。

可以在这里阅读有关收缩包装的信息: https//www.npmjs.org/doc/cli/npm-shrinkwrap.html

所以,在你的本地机器上:

  1. 运行npm install并确保一切正常。
  2. fire npm shrinkwrap这将创建一个文件 - “npm-shrinkwrap.json”,带有所需的shrinkwrap信息。 添加,提交并将文件推送到openshift git repo。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM