【问题标题】:npm doesn't install my packages on my servernpm 不会在我的服务器上安装我的包
【发布时间】:2015-12-16 19:00:49
【问题描述】:

我的应用程序在运行 Ubuntu 14.04 x64 的服务器上运行时遇到问题。我使用聚合物框架开发了一个 javascript 应用程序,它在我的 linux VM 上运行良好。

但是当我将它从我的仓库拉到我的服务器并尝试npm install 模块时,它不起作用。 npm 确实在node_modules/.staging 中安装了一些奇怪的文件,但我没有安装我的模块。

我的node版本是:

$ node -v v4.1.0

我的 npm 版本是:

$ npm-v 3.3.3

我使用了聚合物入门套件中的package.json 文件:https://github.com/PolymerElements/polymer-starter-kit/blob/master/package.json

{
  "private": true,
  "devDependencies": {
    "browser-sync": "^2.7.7",
    "connect-history-api-fallback": "^1.1.0",
    "del": "^1.1.1",
    "glob": "^5.0.6",
    "gulp": "^3.8.5",
    "gulp-autoprefixer": "^2.1.0",
    "gulp-cache": "^0.2.8",
    "gulp-changed": "^1.0.0",
    "gulp-cssmin": "^0.1.7",
    "gulp-if": "^1.2.1",
    "gulp-imagemin": "^2.2.1",
    "gulp-jshint": "^1.6.3",
    "gulp-load-plugins": "^0.10.0",
    "gulp-minify-html": "^1.0.2",
    "gulp-rename": "^1.2.0",
    "gulp-replace": "^0.5.3",
    "gulp-size": "^1.0.0",
    "gulp-uglify": "^1.2.0",
    "gulp-useref": "^1.1.2",
    "gulp-vulcanize": "^6.0.0",
    "jshint-stylish": "^2.0.0",
    "merge-stream": "^0.1.7",
    "polybuild": "^1.0.5",
    "require-dir": "^0.3.0",
    "run-sequence": "^1.0.2",
    "vulcanize": ">= 1.4.2",
    "web-component-tester": "^3.1.3"
  },
  "scripts": {
    "test": "gulp test:local",
    "start": "gulp serve"
  },
  "engines": {
    "node": ">=0.10.0"
  }
}

我尝试只安装 devDependencies 但它也不起作用。

我的服务器托管在 Digital Ocean 上(不过我认为这些信息不相关)。

编辑:我已将我的版本降级为 2.14.3,现在已正确安装软件包。但是我缺少一系列依赖项:

Error: Cannot find module 'lru-cache'

我安装它:

Error: Cannot find module 'sigmund'

【问题讨论】:

  • 你的意思可能是“我试图只安装 devDependencies”,但你有没有运行npm install-dev

标签: node.js ubuntu npm gulp polymer-starter-kit


【解决方案1】:

我可能遗漏了一些东西,但您不应该使用 bower(或任何其他工具)来安装客户端依赖项吗?我认为 npm 仅适用于服务器端包。

我使用这个命令安装聚合物:

bower install --save Polymer/polymer#^1.1.0

【讨论】:

  • AFAIK,凉亭用于元素(例如 Iron-ajax)。 npm 用于 node_modules 依赖项。我尝试在这里运行 gulp 为应用程序创建服务器,因此我需要所有 node_modules 依赖项。
猜你喜欢
  • 1970-01-01
  • 2012-06-28
  • 2015-09-03
  • 2018-06-18
  • 1970-01-01
  • 2018-05-13
  • 1970-01-01
  • 2021-04-12
  • 1970-01-01
相关资源
最近更新 更多