【发布时间】:2017-10-02 15:15:37
【问题描述】:
我有一个关于 npm install 的问题,因为它不会安装 @types。
这很好用
npm install --save lodash
但是不要求类型
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 (git@github.com:types/lodash)
npm ERR! git clone git@github.com: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 git@github.com:types/lodash Host key verification failed.
npm ERR! git clone git@github.com:types/lodash fatal: Could not read from remote repository.
npm ERR! git clone git@github.com:types/lodash
npm ERR! git clone git@github.com:types/lodash Please make sure you have the correct access rights
npm ERR! git clone git@github.com: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>
这让我摸不着头脑。我更新了 Chocolatey、NodeJS、NPM 以确保他们自己的最新版本。在空文件夹或现有 TypeScript 项目上尝试了命令 - 认为在 Git 存储库中运行可能会感到困惑(错误:remote.origin.url)。查看 GitHub URL 没有意义 git://github.com/types/lodash
我从MSDN Blog - The Future of Declaration Files中获取了这些示例
更新:我已卸载 Node.js 并尝试重新安装 v6.11.3 LTS 或 v8.6.0。但是@types 命令仍然失败。
更新 2:我意识到 Chocolately 掩盖了 npm 版本。我删除了 Chocolately 文件夹,并按照@Louis 的回答升级了 npm。
【问题讨论】:
-
看起来你需要有一个配置了私钥的 github 帐户才能使其工作。
-
是的,但是URL本身是错误的github.com/types/lodash???
-
对我来说很好用,你试过更新 npm 吗?
-
尝试降级。
-
当一切都失败时,删除
node_modules/,然后删除npm install
标签: node.js npm windows-10 npm-install