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

ANgular build require Path on build #9856

Open
Mehdi-MST opened this issue Apr 22, 2024 · 2 comments
Open

ANgular build require Path on build #9856

Mehdi-MST opened this issue Apr 22, 2024 · 2 comments

Comments

@Mehdi-MST
Copy link

when we build Angular app it gives an error on 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?

@Mehdi-MST
Copy link
Author

Mehdi-MST commented Apr 22, 2024

I am using the lastest version 5.17.2 and also the version with angular 17

@Mehdi-MST
Copy link
Author

Mehdi-MST commented Apr 26, 2024

using try catch solved the issue
const getAbsoluteFSPath = function () {
// detect whether we are running in a browser or nodejs
if (typeof module !== "undefined" && module.exports) {
try {
return require("path").resolve(__dirname)
}
catch (e) {
throw new Error('Unable to determine the current working directory')
}
}
}

export default getAbsoluteFSPath

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