如何在node.js应用程序中安装正确的模块

时间:2015-12-16 10:02:17

标签: node.js npm

我有node.js应用程序,它在根目录中有package.json文件, 在那里我可以看到我有:

"dependencies": {
    "minimist": "^1.1.0",
    "express": "^4.10.4",
    "redis": "^0.12.1",
    "socket.io": "^1.2.1",
    "socket.io-redis": "^0.1.4"
  },
  "devDependencies": {
    "gulp": "^3.8.10",
    "gulp-jasmine": "^1.0.1",
    "gulp-concat": "^2.4.2",
    "gulp-jshint": "^1.9.0",
    "gulp-myth": "^1.0.2",
    "gulp-minify-css": "^0.3.11",
    "gulp-uglify": "^1.0.2",
    "vinyl-source-stream": "^1.0.0",
    "jasmine-reporters": "^1.0.1",
    "browserify": "^7.0.0",
    "browser-sync": "^1.7.2",
    "del": "^1.1.0",
    "read": "^1.0.5"
  },

我知道节点js需要运行那些js libs, 当我做 : npm ls

i get :
├── UNMET DEPENDENCY express@^4.10.4
├── UNMET DEPENDENCY minimist@^1.1.0
├── UNMET DEPENDENCY redis@^0.12.1
├─┬ socket.io@1.3.7
│ ├─┬ debug@2.1.0
│ │ └── ms@0.6.2
│ ├─┬ engine.io@1.5.4
│ │ ├── base64id@0.1.0
│ │ ├── debug@1.0.3
│ │ ├─┬ engine.io-parser@1.2.2
│ │ │ ├── after@0.8.1
│ │ │ ├── arraybuffer.slice@0.0.6
│ │ │ ├── base64-arraybuffer@0.1.2
│ │ │ ├── blob@0.0.4
│ │ │ └── utf8@2.1.0
│ │ └─┬ ws@0.8.0
│ │   ├─┬ bufferutil@1.2.1
│ │   │ ├── bindings@1.2.1
│ │   │ └── nan@2.1.0
│ │   ├── options@0.0.6
│ │   ├── ultron@1.0.2
│ │   └── utf-8-validate@1.2.1
│ ├─┬ has-binary-data@0.1.3
│ │ └── isarray@0.0.1
│ ├─┬ socket.io-adapter@0.3.1
│ │ ├── debug@1.0.2
│ │ ├── object-keys@1.0.1
│ │ └─┬ socket.io-parser@2.2.2
│ │   └── debug@0.7.4
│ ├─┬ socket.io-client@1.3.7
│ │ ├── backo2@1.0.2
│ │ ├── component-bind@1.0.0
│ │ ├── component-emitter@1.1.2
│ │ ├── debug@0.7.4
│ │ ├─┬ engine.io-client@1.5.4
│ │ │ ├── component-inherit@0.0.3
│ │ │ ├── debug@1.0.4
│ │ │ ├─┬ has-cors@1.0.3
│ │ │ │ └── global@2.0.1
│ │ │ ├── parsejson@0.0.1
│ │ │ ├── parseqs@0.0.2
│ │ │ ├── parseuri@0.0.4
│ │ │ └── xmlhttprequest@1.5.0
│ │ ├── has-binary@0.1.6
│ │ ├── indexof@0.0.1
│ │ ├── object-component@0.0.3
│ │ ├─┬ parseuri@0.0.2
│ │ │ └─┬ better-assert@1.0.2
│ │ │   └── callsite@1.0.0
│ │ └── to-array@0.1.3
│ └─┬ socket.io-parser@2.2.4
│   ├── benchmark@1.0.0
│   ├── debug@0.7.4
│   └── json3@3.2.6
└── UNMET DEPENDENCY socket.io-redis@^0.1.4

npm ERR! missing: minimist@^1.1.0, required by app@0.1.5
npm ERR! missing: express@^4.10.4, required by app@0.1.5
npm ERR! missing: redis@^0.12.1, required by app@0.1.5
npm ERR! missing: socket.io-redis@^0.1.4, required by app@0.1.5

现在我明白他们不见了。 我该怎么安装呢? 我做了npm update -g

1 个答案:

答案 0 :(得分:1)

我刚刚设置了一个包含依赖项的空项目,并做了一个简单的npm install。一切都按预期工作 - 也许这已经是解决方案了。

如果它不起作用,试试这个 - 有时会有所帮助:

rm -rf node_modules
npm install

您还有一些过时的软件包:

Package            Current  Wanted  Latest  Location
browser-sync         1.9.2   1.9.2  2.10.1  test
browserify           7.1.0   7.1.0  12.0.1  test
del                  1.2.1   1.2.1   2.2.0  test
gulp-jasmine         1.0.1   1.0.1   2.2.1  test
gulp-jshint         1.12.0  1.12.0   2.0.0  test
gulp-minify-css     0.3.13  0.3.13   1.2.2  test
jasmine-reporters    1.0.2   1.0.2   2.0.7  test
redis               0.12.1  0.12.1   2.4.2  test
socket.io-redis      0.1.4   0.1.4   1.0.0  test

如果您想更新所有这些内容,请阅读以下内容:How do I update each dependency in package.json to the latest version?

我希望这会有所帮助。

相关问题