Skip to content

Use Node.js dependencies in server-only code #28087

Closed

Description

Command

build

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

Packages like swagger-dist that uses path gives error on build. Using ssr or without ssr.

node_modules/swagger-ui-dist/absolute-path.js:9:19:

const getAbsoluteFSPath = function () {
// detect whether we are running in a browser or nodejs
if (typeof module !== "undefined" && module.exports) {
return require("path").resolve(__dirname)
}
throw new Error('getAbsoluteFSPath can only be called within a Nodejs environment');
}

export default getAbsoluteFSPath

by removing the line return require("path").resolve(__dirname) it solve the issue . any other possible fix for that please?

Minimal Reproduction

Swagger-dist

Exception or Error

require("path").resolve(__dirname) it solve the issue . any other possible fix for that please?

Your Environment

18.0.1

Anything else relevant?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions