GithubHelp home page GithubHelp logo

Broken with new npm 0.3.9 about nstore HOT 10 CLOSED

creationix avatar creationix commented on June 26, 2024
Broken with new npm 0.3.9

from nstore.

Comments (10)

creationix avatar creationix commented on June 26, 2024

Yep, npm dropped support for the modules hash. The irony is I switched to it a while back because Isaac said it was the most future proof. I'm actually not sure how to preserve the require('nstore/pluginX') style modules in the new npm. Care to submit a patch for package.json?

from nstore.

zefhemel avatar zefhemel commented on June 26, 2024

I had the same problem with persistence.js, also wasn't able to preserve the require('.../...') style there either.

Tried to patch it with:

"main": "lib/nstore.js",

But then there seem to be other problems. It says it cannot find the pattern library, which, in turn probably has the same problem.

from nstore.

subpop avatar subpop commented on June 26, 2024

Bleh. This deprecation really requires modules to have a significant amount of code change made to the way they export. If you add:

"directories": {
    "lib": "./lib",
}

to your package.json, you can then access the individual files as such:

var Queue = require('pattern/lib/pattern/queue');

But I think to properly fix this, you have to rewrite pattern in such a way that you can access the submodules like Hash and Queue through the top-level object. Something like:

var pattern = require('pattern');
var hash = pattern.hash;
var queue = pattern.queue;

And inside the pattern module's index.js, you configure your object to export hash and queue. Make sense?

from nstore.

creationix avatar creationix commented on June 26, 2024

Yeah, that's what I usually do. See https://github.com/creationix/creationix/blob/master/index.js for an example. I don't have time to do this right now, but I'll take a pull request.

from nstore.

subpop avatar subpop commented on June 26, 2024

Awesome. I'll fork & try patching this in tonight.

from nstore.

creationix avatar creationix commented on June 26, 2024

Hmm, I wonder if this is a good idea for pattern since the root object it the parent prototype for everything. Then all objects created would have properties stuck no them which is not good. We might need to re-think how the whole thing is structured.

from nstore.

subpop avatar subpop commented on June 26, 2024

It almost feels like with this new structure, you can't export multiple root objects. Hash, Queue and Pattern all have to become independently distributed & require()'d modules. That's what I mean about code changes being required. The way Pattern is written, yea, it almost requires a re-engineering.

Maybe Hash becomes PatternHash?

Or pattern (the root-level-object) becomes a creator for the 3 child objects. Something like:

var PatternGenerator = require('pattern'); // Is a singleton class, to be compatible with npm 0.3.9+
var Hash = PatternGenerator.create('hash'); // Creates a Hash object
var Queue = PatternGenerator.create('queue'); // Creates a Queue object
var Pattern = PatternGenerator.create('pattern'); // or maybe Pattern.create()?

from nstore.

Pita avatar Pita commented on June 26, 2024

I have the same problem :/ Is there any solution avaiable?

from nstore.

sudr avatar sudr commented on June 26, 2024

Any solutions / workarounds. I'm a node.js/nbm noob. So I'd appreciate some detail on the workarounds.

from nstore.

creationix avatar creationix commented on June 26, 2024

Fixed now. I had to refactor pattern and nstore to be friendly to the new npm.

from nstore.

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.