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

Problems calling the library front next.js #124

Open
rundro opened this issue Jun 17, 2023 · 1 comment
Open

Problems calling the library front next.js #124

rundro opened this issue Jun 17, 2023 · 1 comment

Comments

@rundro
Copy link

rundro commented Jun 17, 2023

Hello - I'm running into this error when the node function is being called from a next.js runtime. My file/function works fine when calling directly from node, but it appears to fail to load based on a file path:

  • error unhandledRejection: Error: ENOENT: no such file or directory, open '/Users/username/dev/app/.next/server/app/api/endpoint/../fragments/[Content_Types].xml'

It seems like the next.js runtime is a different path than the node_modules or the Content_Types.xml. I have tried putting the fragments directory in public and fetching the file, i have tried absolute paths, I'm not sure why it's not working when being called by the API. I found the reference in this file which could be causing the issue:

node-pptx/fragments/[Content_Types].xml

    build() {
        xml2js.parseString(fs.readFileSync(`${__dirname}/../fragments/[Content_Types].xml`), (err, js) => {
            this.content['[Content_Types].xml'] = js;
        });

        this.addDefaultMediaContentTypes();
    }
@rundro
Copy link
Author

rundro commented Jun 18, 2023

Fixed this by modifying my next.config.js to include experimental serverComponentsExternalPackages:

module.exports = {
    experimental: { 
      appDir: true,
      serverComponentsExternalPackages: ['nodejs-pptx']
    },
    ```

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

No branches or pull requests

1 participant