bitovi / documentjs

The sophisticated documentation engine
https://documentjs.com/
MIT License
598 stars 381 forks source link

Throws because of multiple versions of can-cid #282

Closed matthewp closed 6 years ago

matthewp commented 7 years ago

Error is:

    throw new Error("You can't have two versions of can-cid, check your dependencies");
    ^

Error: You can't have two versions of can-cid, check your dependencies
    at Object.<anonymous> (file:/Users/matthew/dev/donejs/place-my-order/node_modules/can-cid/can-cid.js:53:8)
    at file:/Users/matthew/dev/donejs/place-my-order/node_modules/can-cid/can-cid.js:58:4
    at file:/Users/matthew/dev/donejs/place-my-order/node_modules/can-cid/can-cid.js:58:98
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at Object.runInThisContext (vm.js:139:38)
    at doEval (/Users/matthew/dev/donejs/place-my-order/node_modules/steal-systemjs/dist/system.src.js:2059:10)
    at __eval (/Users/matthew/dev/donejs/place-my-order/node_modules/steal-systemjs/dist/system.src.js:1976:7)
    at Loader.exec [as __exec] (/Users/matthew/dev/donejs/place-my-order/node_modules/steal-systemjs/dist/system.src.js:339:5)
    at load.metadata.execute (/Users/matthew/dev/donejs/place-my-order/node_modules/steal-systemjs/dist/system.src.js:1217:16)
    at linkDynamicModule (/Users/matthew/dev/donejs/place-my-order/node_modules/steal-systemjs/dist/system.src.js:668:32)
matthewp commented 7 years ago

There aren't actually multiple versions of can-cid. The way documentjs is configured is what causes this. I think a new approach to the build should be taken. I would:

  1. Find the root project's node_modules/ folder.
  2. Copy the entire thing into whereever the build script runs.
  3. Give the build project a package.json with all of its deps.
  4. Run the build as an npm project.
danguilherme commented 7 years ago

I created a new project to try out documentcss and I am having the same issue...

Here's a summary of what I did (TL;DR: followed the tutorial):

$ npm init
$ npm install documentjs --save
$ mkdir styles && touch styles/styles.md # and added the contents from the tutorial
$ touch documentjs.json # and added the contents from the tutorial
$ ./node_modules/.bin/documentjs
jiwebdev commented 6 years ago

I am having the same issue with documentjs. I did everything according to the tutorial but I am getting this same error. Is there a fix?

`...patternlibrary2>.\node_modules.bin\documentjs

Generating styles at styleguide file:C:/****/patternlibrary2/node_modules/can-cid/can-cid.js:52 throw new Error("You can't have two versions of can-cid, check your dependencies"); ^

Error: You can't have two versions of can-cid, check your dependencies at Object. (file:C://patternlibrary2/node_modules/can-cid/can-cid.js: 52:8) at file:C://patternlibrary2/node_modules/can-cid/can-cid.js:57:4 at file:C://patternlibrary2/node_modules/can-cid/can-cid.js:57:98 at ContextifyScript.Script.runInThisContext (vm.js:50:33) at Object.runInThisContext (vm.js:139:38) at doEval (C:\\patternlibrary2\node_modules\steal-systemjs\dist\system.src.js:20 59:10) at __eval (C:**\patternlibrary2\node_modules\steal-systemjs\dist\system.src.js:19 76:7) at Loader.exec [as __exec] (C:**\patternlibrary2\node_modules\steal-systemjs\dist \system.src.js:339:5) at load.metadata.execute (C:**\patternlibrary2\node_modules\steal-systemjs\dist\s ystem.src.js:1217:16) at linkDynamicModule (C:**\patternlibrary2\node_modules\steal-systemjs\dist\syste m.src.js:668:32) `

phillipskevin commented 6 years ago

Changing can-cid to not use a relative path for its own "main" also solved this problem. Changing these two to require("can-cid")... made this error go away on a project we were seeing it on.

https://github.com/canjs/can-cid/blob/161fecf50e80f6a28ead9988ab956afeaa1ff93d/map/map.js#L3

https://github.com/canjs/can-cid/blob/161fecf50e80f6a28ead9988ab956afeaa1ff93d/set/set.js#L2

Should a project be able to import its own main using relative paths, @matthewp ?

phillipskevin commented 6 years ago

Doing this in a simple project (outside documentjs) works fine, so I understand it is documentjs that is causing the problem with its build setup. Ignore my previous question.

ablanco commented 6 years ago

I'm also seeing this issue, I'm using the 0.5.1 To make sure it wasn't an issue with my project, I've done the same as @danguilherme and created a brand new package with only documentcss, and it fails

DreaminDani commented 6 years ago

This also happened to me and I cannot figure out how to fix this. Is there a workaround?

sebs commented 6 years ago

same here fails for a new project, another "living stlye guide generator" that does just does everything, but work

matthewp commented 6 years ago

@sebs it's an open source project, submit a fix.

rucquo-a commented 6 years ago

Hello,

I've been very annoyed by this error recently and I've searched what I could find in my installed modules.

It seems can-cid's security check is very drastic and not compliant at all when called twice (as expected with this error message), however I don't see where documentjs calls it.

I know nothing of can-cid's architecture but I tweaked the security off to see how my project would react, and it looks all ok, but I still have no clue about why this error is thrown.

The tweak is very simple btw, it's only a condition change in the last if in yourProject/node_modules/can-cid/can-cid.js so it enters the else execution.

Update : After removing the security in can-cid, my project didn't fail but on all the ".catch()" that npm asked me to put on asynchronous functions. After removing them, I was able to run again my project, even after can-cid reset. Hope this helps. :crossed_fingers:

justinbmeyer commented 6 years ago

Sorry. We’ve been unable to prioritize documentjs development.

matthewp commented 6 years ago

Should be fixed in https://github.com/bitovi/documentjs/releases/tag/v0.5.2

sebs commented 6 years ago

Thanks! ;)