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

NextJs build fails due to missing module for other platforms #40

Open
felix9607 opened this issue Jul 15, 2024 · 0 comments
Open

NextJs build fails due to missing module for other platforms #40

felix9607 opened this issue Jul 15, 2024 · 0 comments

Comments

@felix9607
Copy link

Hello,

I've created a NextJs App that uses the SDK via npm to retrieve secrets on the server side.

next.config.js:

const os = require('os');
module.exports = {
  webpack: (config, { dev, isServer, webpack, nextRuntime }) => {
    config.module.rules.push({
      test: /\.node$/,
      use: [
        {
          loader: "nextjs-node-loader",
          options: {
            flags: os.constants.dlopen.RTLD_NOW,
            outputPath: config.output.path
          }
        },
      ],
    });
    return config;
  },
};

Infisical.js:

require("dotenv").config();
const { InfisicalClient } = require("@infisical/sdk");
const client = new InfisicalClient({
  siteUrl: "https://app.infisical.com", // Optional, defaults to https://app.infisical.com
  auth: {
    universalAuth: {
      clientId: process.env.INFISICAL_CLIENT_ID,
      clientSecret: process.env.INFISICAL_CLIENT_SECRET,
    },
  },
});

module.exports = {
  async getSecret(key) {
    const { secretValue } = await client.getSecret({
      environment: process.env.NODE_ENV === "production" ? "prod" : "dev",
      projectId: "<PROJECT_ID>",
      path: "/",
      type: "shared",
      secretName: key,
    });
    return secretValue;
  },
};

Running the App via npm run dev works fine but when I try to run a build with npm run build it fails with several errors like for all different platforms that are missing their sdk since npm only installs the one for mac in my case:

./node_modules/@infisical/sdk/binding.js
Module not found: Can't resolve './infisical.android-arm64.node' in '/<PATH>/node_modules/@infisical/sdk'

Import trace for requested module:
./node_modules/@infisical/sdk/binding.js
./node_modules/@infisical/sdk/lib/infisical_client/index.js
./node_modules/@infisical/sdk/lib/index.js
./utils/Infisical.js
./app/api/services/funding/route.js
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