在流浪汉上安装npm

时间:2016-02-08 20:10:21

标签: npm vagrant npm-install

我尝试以两种方式安装和使用npm,但我只得到错误。

以正常方式安装npm:

vagrant@precise64:~$ npm install
npm ERR! Couldn't read dependencies.

npm ERR! Error: ENOENT, no such file or directory '/home/vagrant/package.json'
npm ERR! You may report this log at:
npm ERR!     <http://bugs.debian.org/npm>
npm ERR! or use
npm ERR!     reportbug --attach /home/vagrant/npm-debug.log npm
npm ERR!
npm ERR! System Linux 3.2.0-23-generic
npm ERR! command "node" "/usr/bin/npm" "install"
npm ERR! cwd /home/vagrant
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! path /home/vagrant/package.json
npm ERR! code ENOENT
npm ERR! message ENOENT, no such file or directory '/home/vagrant/package.json'
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/vagrant/npm-debug.log
npm not ok

尝试安装最新版本:

vagrant@precise64:~$ npm install -g npm@latest
npm http GET https://registry.npmjs.org/npm

npm ERR! Error: failed to fetch from registry: npm
npm ERR!     at /usr/share/npm/lib/utils/npm-registry-client/get.js:139:12
npm ERR!     at cb (/usr/share/npm/lib/utils/npm-registry-client/request.js:31:9)
npm ERR!     at Request._callback (/usr/share/npm/lib/utils/npm-registry-client/request.js:136:18)
npm ERR!     at Request.callback (/usr/lib/nodejs/request/main.js:119:22)
npm ERR!     at Request.<anonymous> (/usr/lib/nodejs/request/main.js:212:58)
npm ERR!     at Request.emit (events.js:88:20)
npm ERR!     at ClientRequest.<anonymous> (/usr/lib/nodejs/request/main.js:412:12)
npm ERR!     at ClientRequest.emit (events.js:67:17)
npm ERR!     at HTTPParser.onIncoming (http.js:1261:11)
npm ERR!     at HTTPParser.onHeadersComplete (http.js:102:31)
npm ERR! You may report this log at:
npm ERR!     <http://bugs.debian.org/npm>
npm ERR! or use
npm ERR!     reportbug --attach /home/vagrant/npm-debug.log npm
npm ERR!
npm ERR! System Linux 3.2.0-23-generic
npm ERR! command "node" "/usr/bin/npm" "install" "-g" "npm@latest"
npm ERR! cwd /home/vagrant
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! message failed to fetch from registry: npm
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/vagrant/npm-debug.log
npm not ok

在创建这个package.json文件之前我应该​​安装什么才能使它工作?

1 个答案:

答案 0 :(得分:0)

npm看起来已经安装好了。转到您的项目根目录:

npm init

它将指导您制作package.json文件,然后您可以

npm i whateverpackageyouwant

你心中的内容。