我在npm安装方面有个问题,因为它不会安装@type。
这个很好用
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>这让我抓挠了头。我更新了巧克力,NodeJS,NPM,以确保他们自己的最新版本。尝试在空文件夹或现有的TypeScript项目上执行命令--认为在Git存储库中运行可能会感到困惑(error: remote.origin.url)。查看GitHub网址,它没有任何意义,git://github.com/type/
我从MSDN博客-宣言文件的未来那里学到了这些例子
更新:我已卸载Node.js并尝试重新安装v6.11.3 LTS或v8.6.0。但是,@type命令仍然失败。
更新2:我意识到巧克力掩盖了npm的版本。我删除了巧克力文件夹,并升级了npm作为@Louis的答案。
发布于 2017-10-11 11:47:07
将您的npm版本升级到version 4或5。我提到了4,因为我遇到了5的问题,而且使用4仍然可行。我不知道有什么好的理由去运行旧的版本。
您使用的是npm版本1.4.9,如日志的这一行所示:
npm ERR! npm -v 1.4.9问题是版本2之前的npm 版本不支持作用域包。以@开头的包是作用域包,因此@types/lodash是一个作用域包。安装它需要npm版本2或更高版本。如果要在1.x系列(1.4.29)中使用最新的npm,您会得到更好的错误消息:
npm ERR! Error: This version of npm doesn't support scoped packages (caused by reference to @types/lodash). Update to npm@2+.版本1.4.9甚至不知道范围内的包是一件事,所以它不能给出一个很好的错误信息。看起来它使用了@符号来表示包名是一个地址,并填写了丢失的信息,并将Github作为默认主机。
我通常用于升级npm的升级命令是:
npm install -g npm可以通过将npm参数替换为提供特定版本号的参数来指定特定版本。例如,npm@4将在4.x系列中安装最新的npm。如果不指定版本号,则会得到最新发布的版本。
https://stackoverflow.com/questions/46528456
复制相似问题