Tôi gặp sự cố với cài đặt npm, ở chỗ nó sẽ không cài đặt @types.NPM không thể cài đặt các loại
này hoạt động tốt
npm install --save lodash
Tuy nhiên yêu cầu loại không
npm install --save @types/lodash
PS C:\Development\Temp> npm install --save @types/lodash
npm WARN `git config --get remote.origin.url` returned wrong result (git://github.com/types/lodash)
npm WARN `git config --get remote.origin.url` returned wrong result ([email protected]:types/lodash)
npm ERR! git clone [email protected]:types/lodash Cloning into bare repository 'C:\Users\myuser\AppData\Roaming\npm-cache\_git-remotes\git-github-com-types-lodash-9eb5372a'...
npm ERR! git clone [email protected]:types/lodash Host key verification failed.
npm ERR! git clone [email protected]:types/lodash fatal: Could not read from remote repository.
npm ERR! git clone [email protected]:types/lodash
npm ERR! git clone [email protected]:types/lodash Please make sure you have the correct access rights
npm ERR! git clone [email protected]:types/lodash and the repository exists.
npm ERR! addLocal Could not install types/lodash
npm ERR! Error: ENOENT: no such file or directory, stat 'C:\Development\Temp\types\lodash'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Windows_NT 10.0.15063
npm ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\ProgramData\\chocolatey\\lib\\npm\\tools\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save" "@types/lodash"
npm ERR! cwd C:\Development\Temp
npm ERR! node -v v8.6.0
npm ERR! npm -v 1.4.9
npm ERR! path C:\Development\Temp\types\lodash
npm ERR! syscall stat
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Development\Temp\npm-debug.log
npm ERR! not ok code 0
PS C:\Development\Temp>
này đã bị tôi gãi đầu của tôi. Tôi đã cập nhật Chocolatey, NodeJS, NPM để đảm bảo phiên bản mới nhất của riêng họ. Đã thử các lệnh trên các thư mục trống hoặc một dự án TypeScript hiện có - nghĩ rằng nó có thể bị nhầm lẫn khi được chạy trong một kho lưu trữ Git (error: remote.origin.url). Nhìn vào URL GitHub nó làm cho không có ý nghĩa git: //github.com/types/lodash
tôi lấy những ví dụ từ MSDN Blog - The Future of Declaration Files
Cập nhật: Tôi đã gỡ bỏ cài đặt Node.js và thử cài đặt lại v6.11.3 LTS hoặc v8.6.0. Tuy nhiên lệnh @types vẫn không thành công.
Cập nhật 2: Tôi đã nhận ra rằng Chocolately đang che giấu phiên bản npm. Tôi đã xóa thư mục Chocolately và nâng cấp npm theo câu trả lời @Louis.
Có vẻ như bạn được yêu cầu có tài khoản github có khóa cá nhân được định cấu hình để làm cho nó hoạt động. – lilezek
Có, nhưng chính URL đó là sai github.com/types/lodash ??? – wonea
Làm việc tốt cho tôi, bạn đã thử cập nhật npm chưa? –