Npm 错误-没有找到匹配的版本

我用 git 克隆了一个项目,这个项目是用 ionic 2创建的,但是当我执行命令重新创建 node _ module 文件夹时,我得到了这个错误。

npm install
npm WARN deprecated object-keys@0.2.0: Please update to the latest object-keys
npm ERR! code ETARGET
npm ERR! notarget No matching version found for ionic-native@^3.5.0
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'ionic-hello-world'
npm ERR! notarget


npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/wihermes/.npm/_logs/2017-06-02T13_58_47_295Z-debug.log

注意: 我已经更新了 npm。

有人知道怎么修吗?

307485 次浏览

The version you have specified, or one of your dependencies has specified is not published to npmjs.com

Executing npm view ionic-native (see docs) the following output is returned for package versions:

versions:
[ '1.0.7',
'1.0.8',
'1.0.9',
'1.0.10',
'1.0.11',
'1.0.12',
'1.1.0',
'1.1.1',
'1.2.0',
'1.2.1',
'1.2.2',
'1.2.3',
'1.2.4',
'1.3.0',
'1.3.1',
'1.3.2',
'1.3.3',
'1.3.4',
'1.3.5',
'1.3.6',
'1.3.7',
'1.3.8',
'1.3.9',
'1.3.10',
'1.3.11',
'1.3.12',
'1.3.13',
'1.3.14',
'1.3.15',
'1.3.16',
'1.3.17',
'1.3.18',
'1.3.19',
'1.3.20',
'1.3.21',
'1.3.22',
'1.3.23',
'1.3.24',
'1.3.25',
'1.3.26',
'1.3.27',
'2.0.0',
'2.0.1',
'2.0.2',
'2.0.3',
'2.1.2',
'2.1.3',
'2.1.4',
'2.1.5',
'2.1.6',
'2.1.7',
'2.1.8',
'2.1.9',
'2.2.0',
'2.2.1',
'2.2.2',
'2.2.3',
'2.2.4',
'2.2.5',
'2.2.6',
'2.2.7',
'2.2.8',
'2.2.9',
'2.2.10',
'2.2.11',
'2.2.12',
'2.2.13',
'2.2.14',
'2.2.15',
'2.2.16',
'2.2.17',
'2.3.0',
'2.3.1',
'2.3.2',
'2.4.0',
'2.4.1',
'2.5.0',
'2.5.1',
'2.6.0',
'2.7.0',
'2.8.0',
'2.8.1',
'2.9.0' ],

As you can see no version higher than 2.9.0 has been published to the npm repository. Strangely they have versions higher than this on GitHub. I would suggest opening an issue with the maintainers on this.

For now you can manually install the package via the tarball URL of the required release:

npm install https://github.com/ionic-team/ionic-native/tarball/v3.5.0

Try removing package-lock.json file first

Try removing package-lock.json and running npm install && npm update, it'll install the latest version and clear all errors.

Removing package-lock.json should be the last resort, at least for projects that have reached production status. After having the same error as described in this question, I found that my package-lock.json was corrupt, even though it was generated. One of the packages had itself as an empty dependency, in this example jsdoc:

        "jsdoc": {
"version": "x.y.z",
. . . . . .
"dependencies": {
. . . . . ,
"jsdoc": {},
"taffydb": {
. . . . .

Please note I have omitted irrelevant parts of the code in this example.

I just removed the empty dependency "jsdoc": {}, and it was OK again.

Probably not the case of everybody but I had the same problem. I was using the last, in my case, the error was because I was using jfrog manage from the company where I am working.

 npm config list

The result was

; cli configs
metrics-registry = "https://COMPANYNAME.jfrog.io/COMPANYNAM/api/npm/npm/"
scope = ""
user-agent = "npm/6.3.0 node/v8.11.2 win32 x64"


; userconfig C:\Users\USER\.npmrc
always-auth = true
email = "XXXXXXXXX"
registry = "https://COMPANYNAME.jfrog.io/COMPANYNAME/api/npm/npm/"


; builtin config undefined
prefix = "C:\\Users\\XXXXX\\AppData\\Roaming\\npm"


; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\WINDOWS\system32
; HOME = C:\Users\XXXXXX
; "npm config ls -l" to show all defaults.

I solve the problem by using the global metrics.

If none of this did not help, then try to swap ^ in "^version" to ~ "~version".

first, in C:\users\your PC write npm uninstall -g create-react-app then, create your project folder with npx create-react-app folder-name.

try

npm install --force
npm install --legacy-peer-deps

I was having issue for a package which was available. Force cleaning the cache helped.

npm cache clean --force

For those experimenting with creating their own packages, make sure that you dont skip a version. For instance, if I have published my-package 1.0.1 & 1.0.3, when I go to install it from elsewhere I will get an error notarget No matching version found for my-package@1.0.2.

The good news is it is fairly easy to fix, simply 'backfill' the empty version.

  1. edit package.json -> "version": "1.0.2"
  2. npm publish

EDIT: As suggested in comment, clearing the cache will solve the problem locally

  • npm cache clean --force

To solve the issue:

Delete your package-lock.json or yarn.lock

Run npm cache clean --force

Then npm install or yarn install again.

In my case I was needed to do the following steps: The 1st step is outdated, so it could be skipped (most probably)

npm cache clean --force
npm cache verify
npm uninstall yourPackage
npm uninstall -g yourPackage

My problem is described here

After these steps the application was generated successfully.

Remove node_modules, cache files (normally are at the top of the folder in your editor) and the package-lock.json, then run npm install.

Haven't seen it mentionned yet, for me it was my project's .npmrc file that was pointing to the wrong npm registry, as we're using Azure DevOps Package Registry.

For me the problem was that I issued the command:

npm publish dist

While this other command works:

npm publish dist/

The log was not intuitive.