Coder Social home page Coder Social logo

Comments (10)

timbru31 avatar timbru31 commented on July 28, 2024

Is git+ even still valid? I remember npm had some issue with it a time ago. Anyways, installing from Git just works like this:
cordova plugin add https://github.com/wbt11a/Canvas2ImagePlugin.git\#6195584c2b

from cordova-fetch.

dpogue avatar dpogue commented on July 28, 2024

I've fought variations of this for years, with most reliable format to install from github is using the same github: syntax as npm:

cordova plugin add github:wbt11a/Canvas2ImagePlugin#6195584c2b

from cordova-fetch.

liuxiaoy avatar liuxiaoy commented on July 28, 2024

thanks @timbru31 @dpogue. Npm install support github, https and git all. but this not my problem.

My problem is npa(npm-package-arg) won't
resolve name of the plugin whose repo like https://,git://,GitHub:.So cordova-fetch will exec npm to install it, but it exists already.

from cordova-fetch.

breautek avatar breautek commented on July 28, 2024

@timbru31 NPM automatically converts git urls to git+

I've failed to reproduce this on:

My output:

norman@norman-ThinkPad:/development/cordova/tests/android29$ cordova plugin add https://github.com/wbt11a/Canvas2ImagePlugin.git#6195584c2b
Installing "org.wbt11a.Canvas2ImagePlugin" for android
Adding org.wbt11a.Canvas2ImagePlugin to package.json
norman@norman-ThinkPad:/development/cordova/tests/android29$ cordova plugin add https://github.com/wbt11a/Canvas2ImagePlugin.git#6195584c2b
Plugin "org.wbt11a.Canvas2ImagePlugin" already installed on android.
Adding org.wbt11a.Canvas2ImagePlugin to package.json
norman@norman-ThinkPad:/development/cordova/tests/android29$ npm install && cordova prepare
npm WARN [email protected] requires a peer of ajv@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No repository field.

audited 151 packages in 2.221s
found 1 low severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details

norman@norman-ThinkPad:/development/cordova/tests/android29$ rm -rf node_modules/
norman@norman-ThinkPad:/development/cordova/tests/android29$ npm install && cordova prepare
npm WARN [email protected] No repository field.

added 402 packages from 282 contributors and audited 151 packages in 7.15s
found 1 low severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details

I'm using Node 12.15.0 & NPM 6.13.4.

Are you able to provide a sample minimal reproduction app?

from cordova-fetch.

liuxiaoy avatar liuxiaoy commented on July 28, 2024

@breautek

rm -r platforms plugins

before exec "cordova prepare"

no need "rm -rf node_modules/"

from cordova-fetch.

breautek avatar breautek commented on July 28, 2024

Strange... when I do that, I'm seeing a completely different error...

norman@norman-ThinkPad:/development/cordova/tests/android29$ npm install && cordova prepare
npm WARN [email protected] No repository field.

added 56 packages from 39 contributors and audited 68 packages in 4.177s

1 package is looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Discovered platform "[email protected]" in config.xml or package.json. Adding it to the project
Using cordova-fetch for [email protected]
Adding android project...
Creating Cordova project for the Android platform:
	Path: platforms/android
	Package: com.breautek.api29
	Name: HelloCordova
	Activity: MainActivity
	Android target: android-28
Subproject Path: CordovaLib
Subproject Path: app
Android project created with [email protected]
Discovered saved plugin "cordova-plugin-whitelist". Adding it to the project
Installing "cordova-plugin-whitelist" for android
Discovered saved plugin "org.wbt11a.Canvas2ImagePlugin". Adding it to the project
Failed to restore plugin "org.wbt11a.Canvas2ImagePlugin" from config.xml. You might need to try adding it again. Error: Error: npm: Command failed with exit code 1 Error output:
npm ERR! code E404
npm ERR! 404 'org.wbt11a.Canvas2ImagePlugin' is not in the npm registry.
npm ERR! 404 name can no longer contain capital letters
npm ERR! 404 
npm ERR! 404  'org.wbt11a.Canvas2ImagePlugin@latest' is not in the npm registry.
npm ERR! 404 Your package name is not valid, because 
npm ERR! 404  1. name can no longer contain capital letters
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/norman/.npm/_logs/2020-04-13T13_29_53_098Z-debug.log

For me it looks like it's attempting to install by name (so for me I think it is determining the package name properly), but then it fails because it's not an actual NPM package because well, it should be installing from git... not from the NPM repository.

The relevant parts of my package.json file looks like:

"dependencies": {
    "canvas2imageplugin": "git+https://github.com/wbt11a/Canvas2ImagePlugin.git#6195584c2b",
    "cordova-android": "8.1.0"
  },
  "devDependencies": {
    "cordova-plugin-whitelist": "^1.3.4"
  },
  "cordova": {
    "plugins": {
      "cordova-plugin-whitelist": {},
      "org.wbt11a.Canvas2ImagePlugin": {}
    },
    "platforms": [
      "android"
    ]
  }

from cordova-fetch.

liuxiaoy avatar liuxiaoy commented on July 28, 2024

@breautek It loos like cordova is executing npm install org.wbt11a.Canvas2ImagePlugin. But this plugin should has been download by npm install. This step is unnecessary.

To fix this question above,use

"dependencies": {
    "org.wbt11a.Canvas2ImagePlugin": "git+https://github.com/wbt11a/Canvas2ImagePlugin.git#6195584c2b"
  },

from cordova-fetch.

raphinesse avatar raphinesse commented on July 28, 2024

@liuxiaoy I am 90% sure that the weird Error that @breautek (and myself) observed when trying to prepare a project with the plugin, stems from the fact that the ID in the plugin.xml (org.wbt11a.Canvas2ImagePlugin) differs from the name in package.json (canvas2imageplugin). I don't know if we support this, but I think we should not.

Anyway, this does not seem to be what this issue is about. You write

the plugin has been download when npm install
no need to download it when cordova prepare

Unfortunately, the package caching done by cordova-fetch only works for packages referenced by name and version. cordova-fetch will always download a package when it is given an URL. That is because we cannot translate an URL into a package name to check if we already have the package installed.

If I understood you correctly, I would say everything works as intended. Thus I am closing this issue. If you feel that I misunderstood the issue, please provide additional detail and clear step by step instructions to reproduce your issue.

from cordova-fetch.

liuxiaoy avatar liuxiaoy commented on July 28, 2024

@raphinesse Yes, my problem is
“cordova-fetch will always download a package when it is given an URL”.

So "cordova plugin add [email protected]" differs from "cordova plugin add https://github.com/apache/cordova-plugin-camera.git#2.0.0". Maybe it would be better to show this difference On the official guide website.

from cordova-fetch.

liuxiaoy avatar liuxiaoy commented on July 28, 2024

@raphinesse Or Maybe we can translate an URL into a package name by the package installed.I'll have a try.

from cordova-fetch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.