Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifying a forked npm package is not possible #4455

Closed
patmoore opened this issue May 26, 2015 · 4 comments
Closed

Specifying a forked npm package is not possible #4455

patmoore opened this issue May 26, 2015 · 4 comments

Comments

@patmoore
Copy link
Contributor

(You can also answer it over here: http://stackoverflow.com/questions/30466824/in-meteor-how-to-use-a-npm-library-that-should-be-pulled-from-a-repository )

In my packages.json file, I have:

{
    "sendwithus":"git+https://git@github.com/whalepath/sendwithus_nodejs.git#enable_testing_server"
}

because I need to use a forked ( and fixed version of the library). The above syntax works in straight node. How to do this in meteor?

This is the error I get:

=> Started proxy.                             
=> Errors prevented startup:                  
While reading package from `src/packages/npm-container`:
package.js:14:7: must declare exact version of dependency:
   sendwithus@git+https://git@github.com/whalepath/sendwithus_nodejs.git#enable_testing_server
Update:

I tried removing the line and using meteor add to get the package included:

Failed:

$ meteor add sendwithus@2.9.1@https://github.com/whalepath/sendwithus_nodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4

=> Errors while parsing arguments:           

While adding package sendwithus@2.9.1@https://github.com/whalepath/sendwithus_nodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4:
error: Package names can only contain lowercase ASCII alphanumerics, dash, dot, or colon, not "@".

Failed:

$ meteor add sendwithus@2.9.1_https://github.com/whalepath/sendwithus_nodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4
 => Errors while parsing arguments:           

While adding package sendwithus@2.9.1_https://github.com/whalepath/sendwithus_nodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4:
error: Can't have two _ in version: 2.9.1_https://github.com/whalepath/sendwithus_nodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4

Failed:

$ meteor add server:sendwithus@2.9.1@https://github.com/whalepath/sendwithus_nodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4
 => Errors while parsing arguments:           

While adding package server:sendwithus@2.9.1@https://github.com/whalepath/sendwithus_nodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4:
error: Package names can only contain lowercase ASCII alphanumerics, dash, dot, or colon, not "@".

Failed:

$ meteor add sendwithus@https://github.com/whalepath/sendwithusnodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4
=> Errors while parsing arguments:           

While adding package sendwithus@https://github.com/whalepath/sendwithusnodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4:
error: Version string must look like semver (eg '1.2.3'), not 'https://github.com/whalepath/sendwithusnodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4'.
@glasser
Copy link
Contributor

glasser commented May 26, 2015

"How can I do this?" questions are best posed on StackOverflow or the Meteor forums, not our bug tracker.

meteod add doesn't currently work with npm packages; specifying with Npm.depends is what you want. We wanted to encourage people to make their Meteor packages reproducible by always declaring explicit versions, so URLs need to contain the 40-character hash in it. (This may have been misguided but it is the status quo.)

So

Npm.depends({sendwithus: "https://github.com/whalepath/sendwithusnodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4"});

should do the trick.

@glasser glasser closed this as completed May 26, 2015
@patmoore
Copy link
Contributor Author

I did ask this question over on stackoverflow. (no response)

Plus the error message indicated that it may not be possible to directly reference the npm fork/branch.

Npm.depends() does not exist in the main code base. Npm.depends() only exists when processing a meteor package.

It looks like you are saying that I need to create a fake meteor package to wrap the the forked npm package.

So I can't just point the packages.json at the location like I can in package.json in a plain node project?

@glasser
Copy link
Contributor

glasser commented May 26, 2015

Because that is how the Meteor platform's npm integration was designed.

@patmoore
Copy link
Contributor Author

Just to use a fork of a npm library requires:

  1. main.js:
SendWithUs = Npm.require('sendwithus');
  1. package.js:
Package.describe({
  summary: 'Wrapped sendwithus library',
  version: '2.9.1',
  name: 'sendwithus'
});
Npm.depends({sendwithus: "https://github.com/whalepath/sendwithus_nodejs/tarball/41b0d177f6eabf02de2daec9bb2b36daebbfbef4"});
Package.onUse(function(api){
    api.addFiles('main.js', 'server');
    api.export('SendWithUs');
});
  1. removing the reference in the packages.json
  2. meteor add sendwithus

Maybe this could be improved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants