CodeforLeipzig / wo-ist-testzentrum

https://wo-ist-testzentrum.de/#leipzig
Other
7 stars 4 forks source link

Fix node error when running preprocessor for Berlin. #37

Closed johnjohndoe closed 2 years ago

johnjohndoe commented 2 years ago

Error output

$ node preprocessing/berlin/compile-berlin-geojson.js > cities/berlin.json  
node:internal/modules/cjs/loader:1125
      throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
      ^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: wo-ist-testzentrum/node_modules/node-fetch/src/index.js
require() of ES modules is not supported.
require() of wo-ist-testzentrum/node_modules/node-fetch/src/index.js from 
  wo-ist-testzentrum/preprocessing/berlin/compile-berlin-geojson.js is an ES module file as it is a .js file
  whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope
  as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module"
  from wo-ist-testzentrum/node_modules/node-fetch/package.json.

    at new NodeError (node:internal/errors:363:5)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1125:13)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Function.Module._load (node:internal/modules/cjs/loader:828:14)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:93:18)
    at Object.<anonymous> (wo-ist-testzentrum/preprocessing/berlin/compile-berlin-geojson.js:4:15)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Module.load (node:internal/modules/cjs/loader:988:32) {
  code: 'ERR_REQUIRE_ESM'
}
johnjohndoe commented 2 years ago

@mojoaxel Does this look correct to you?

johnjohndoe commented 2 years ago

I successfully tested it locally. :shipit: