api-platform / admin

A beautiful and fully-featured administration interface builder for hypermedia APIs
https://api-platform.com/docs/admin/
MIT License
481 stars 130 forks source link

Build error with v3.1.1: json-refs/index.js" contains a reference to the file "path" #453

Closed Gamesh closed 2 years ago

Gamesh commented 2 years ago

API Platform version(s) affected: 3.1.1 yarn version: 1.22.18

Description
Module build failed: Module not found: "./node_modules/json-refs/index.js" contains a reference to the file "path". This file can not be found, please check it for typos or update it if the file got moved.

How to reproduce

This started happening after upgrade from 2.8 to 3.1.1

Any ideas?

alanpoulain commented 2 years ago

Could you check your version of @api-platform/api-doc-parser please?

Gamesh commented 2 years ago

@alanpoulain yarn list | grep @api-platform

├─ @api-platform/admin@3.1.1
│  ├─ @api-platform/api-doc-parser@^0.14.3
├─ @api-platform/api-doc-parser@0.14.3
Gamesh commented 2 years ago

strange but it seems by installing a https://www.npmjs.com/package/node-polyfill-webpack-plugin plugin the issue gets resolve, but not sure why i need this, everywhere else require("path") seems to work fine

alanpoulain commented 2 years ago

That's weird, json-refs has been added to api-doc-parser recently. I don't know why its path dependency doesn't have a polyfill by default and why it doesn't work in your specific case.

Gamesh commented 2 years ago

do you want me to add anything extra? webpack config? packages.json? what could help to debug

alanpoulain commented 2 years ago

It could be great if you can reproduce the issue in an empty project.

Gamesh commented 2 years ago

Good morning @alanpoulain i've created a repo with reproducible case https://github.com/Gamesh/api-platform-453

just run yarn build

jvasseur commented 2 years ago

I'm having the same problem with a slightly more detailed error message : image

It looks like it's a webpack version/config problem but what I'm doing is just adding @api-platform/admin to a create-react-app project so having the admin fail on such a "standard" installation is quite annoying.

Gamesh commented 2 years ago

strange but it seems by installing a npmjs.com/package/node-polyfill-webpack-plugin plugin the issue gets resolve, but not sure why i need this, everywhere else require("path") seems to work fine

@jvasseur you can workaround it using node-polyfill-webpack-plugin

jvasseur commented 2 years ago

@Gamesh yes but that needs moving out of create-react-app since CRA doesn't allow overriding the webpack config to add plugins.

alanpoulain commented 2 years ago

Should be solved by https://github.com/api-platform/api-doc-parser/pull/114.

jvasseur commented 2 years ago

This is effectively solved in the last version, thanks for taking the time to do it.

Gamesh commented 2 years ago

Awesome 👏 thank you a lot