heavysixer / node-pptx

Generate PPTX files on the server-side with JavaScript.
MIT License
161 stars 44 forks source link

deep require is no longer supported for uuid library #70

Open hannaol opened 3 years ago

hannaol commented 3 years ago

First of all, thank you for your very helpful library !

I ran into the following problem: In the file node-pptx/lib/factories/ppt/index.js line 5 a deep requires is used for the uuid library : const uuidv4 = require('uuid/v4'); According to their page this is deprecated and no longer supported: https://github.com/uuidjs/uuid#deep-requires-no-longer-supported

Therefore the following error is thrown in my project: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './v4' is not defined by "exports" in .../node_modules/uuid/package.json

heavysixer commented 3 years ago

@gregdolley Would you mind checking this out?

gregdolley commented 3 years ago

Will do!

On Tue, Jan 12, 2021, 09:59 Mark Daggett notifications@github.com wrote:

@gregdolley https://github.com/gregdolley Would you mind checking this out?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/heavysixer/node-pptx/issues/70#issuecomment-758834572, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABN3O6L7EO5BRN64RSHLFQDSZSEYVANCNFSM4UFDGIVA .

gregdolley commented 3 years ago

@heavysixer: this is popping up because we use "require" the uuid library like this in many places:

    const uuidv4 = require('uuid/v4');

...where there is a "uuid/" inside the require param. The warning is telling us, that in uuid lib v7.x (we are on 3.x), we can't import it like this anymore, but rather should use the "import" syntax or something like: "const { v4: uuidv4 } = require('uuid');" for commonJS. But since we're still on v3.x, we shouldn't have to worry about this. I'll try and find why @hannaol was still getting this error.

gregdolley commented 3 years ago

@hannaol - what version of node are you running your code under? Also, could you please post the part of your code that is causing this error?

Thanks!

Able1991 commented 3 years ago

An error occurs when using require("node js-pptx"); Maybe the problem is that the version is not explicitly specified in the dependencies?

image

volyansky commented 2 years ago

The issue is still present and makes the library unusable Any updates about the fix?

hannaol commented 2 years ago

Sorry, i totally forgot about replying to this!

So for me the issue was caused because another library in my project was also using uuid, but version 8. As far as i can remember i installed that dependency before adding nodejs-pptx. I was able to fix this by including "uuid": "~7" in the dependencies in the package.json of my project and doing a clean install.

(node version 12, and the code that caused this error to arise was the code sample to create a new powerpoint presentation, as far as i can remember)