heavysixer / node-pptx

Generate PPTX files on the server-side with JavaScript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

deep require is no longer supported for uuid library

hannaol opened this issue · comments

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

@gregdolley Would you mind checking this out?

@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.

@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!

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

image

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

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)