mledoze / countries

World countries in JSON, CSV, XML and Yaml. Any help is welcome!
https://mledoze.github.io/countries/
Open Data Commons Open Database License v1.0
5.92k stars 1.26k forks source link

export { default } from './countries.json' assert { type: 'json' }; #502

Closed fahad39 closed 6 months ago

fahad39 commented 9 months ago

After installing via NPM or yarn in react. This error will show up "export { default } from './countries.json' assert { type: 'json' };" in production you can manually remove the part "assert {type:"json}" but not in production

Version : 5.0.0

mledoze commented 9 months ago

Hi,

thanks for the report.

you can manually remove the part "assert {type:"json}" but not in production

I did not understand this part. Could you describe the steps to reproduce this error?

fahad39 commented 9 months ago

Hi,

thanks for the report.

you can manually remove the part "assert {type:"json}" but not in production

I did not understand this part? Could you describe the steps to reproduce this error?

yes, so just install the latest verison in your react applicaion and start the server and it will show this error and then you have to go to nodes modules find the library and remove the line from the file.

paulschreiber commented 8 months ago

This is the error we get:

SyntaxError: /home/runner/work/terraso-web-client/terraso-web-client/n
ode_modules/world-countries/index.mjs: Support for the experimental syntax 
'importAttributes' isn't currently enabled (1:44):
> 1 | export { default } from './countries.json' assert { type: 'json' };
    |                                            ^
  2 |

Add @babel/plugin-syntax-import-attributes (https://github.com/babel/babel/
tree/main/packages/babel-plugin-syntax-import-attributes) to the 'plugins'
section of your Babel config to enable parsing.
    at parser.next (<anonymous>)
    at normalizeFile.next (<anonymous>)
    at run.next (<anonymous>)
    at transform.next (<anonymous>)
  1. The assert syntax is deprecated — don't use that.
  2. Since we are using react-scripts, we can't easily customize babel, so installing the plugin and updating package.json won't work.
    1. Even trying the workaround suggested in StackOverflow fails (with the same errors).

Can you make v5 work with a default-configuration React app (as v4 does)?

mledoze commented 6 months ago

fixed via #504

@fahad39 could you try again with the version on master?