Vì vậy, tôi đã cố gắng tự khắc phục điều này trong một vài giờ và tôi cảm thấy mình đã làm nó tồi tệ hơn. Tôi đang chạy Kbfox 12.10 và đang cố gắng cài đặt nodejs và npm với tư cách là người dùng chưa root để tôi có thể cài đặt khung đóng trò chơi. Tôi đã có một phiên bản của nút và npm được cài đặt dưới dạng root. Sau đó, cố gắng cài đặt lại (không xóa cái cũ) thông qua các hướng dẫn sau: http://tnovelli.net/blog/blog.2011-08-27.node-npm-user-install.html
Bây giờ khi tôi gõ which npm
tôi không nhận được gì. Tuy nhiên khi tôi gõ which node
tôi nhận được /home/myusername/.local/bin/node
. Vì vậy, tôi giả sử nút được cài đặt chính xác.
còn khi tôi gõ npm -v
Tôi có:
The program 'npm' is currently not installed. You can install it by typing:
sudo apt-get install npm
Vì vậy, tôi gõ sudo apt-get install npm
và câu trả lời là:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
npm : Depends: nodejs (>= 0.6.19~dfsg1-3) but it is not going to be installed
Depends: nodejs-dev
Depends: node-node-uuid but it is not going to be installed
Depends: node-request but it is not going to be installed
Depends: node-mkdirp but it is not going to be installed
Depends: node-minimatch but it is not going to be installed
Depends: node-semver but it is not going to be installed
Depends: node-ini but it is not going to be installed
Depends: node-graceful-fs but it is not going to be installed
Depends: node-abbrev but it is not going to be installed
Depends: node-nopt but it is not going to be installed
Depends: node-fstream but it is not going to be installed
Depends: node-rimraf but it is not going to be installed
Depends: node-tar but it is not going to be installed
Depends: node-which but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Làm thế nào tôi có thể sửa lỗi này để tôi có thể cài đặt npm theo liên kết ở trên?
EDIT: sau khi tìm kiếm thêm một số tôi đã thử sudo apt-get clean && sudo apt-get update
và thậm chí sau đó tôi vẫn nhận được thông báo tương tự sau khi thử apt-get npm
nvm
và bắt đầu các kịch bản như sudo node myscript.js
mọi lúc.
nvm