laverdet / xxscreeps

Other
71 stars 16 forks source link

Unable to run `npx xxscreeps import` #61

Open UndefinedCpp opened 1 year ago

UndefinedCpp commented 1 year ago

I followed the instructions, installed and compiled, but unable to run npx xxscreeps import. I got the following error:

node:internal/process/esm_loader:97
    internalBinding('errors').triggerUncaughtException(
                              ^
TypeError [ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module "file:///home/lighthouse/xxscreeps/dist/engine/db/user/badge.schema.json" needs an import assertion of type "json"
    at __node_internal_captureLargerStackTrace (node:internal/errors:477:5)
    at new NodeError (node:internal/errors:387:5)
    at validateAssertions (node:internal/modules/esm/assert:82:15)
    at defaultLoad (node:internal/modules/esm/load:84:3)
    at nextLoad (node:internal/modules/esm/loader:165:28)
    at ESMLoader.load (node:internal/modules/esm/loader:608:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:464:22)
    at new ModuleJob (node:internal/modules/esm/module_job:63:26)
    at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:483:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:441:34)
    at async ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:78:21)
    at async Promise.all (index 1)
    at async link (node:internal/modules/esm/module_job:83:9) {
  code: 'ERR_IMPORT_ASSERTION_TYPE_MISSING'
}

How can I fix this? Thanks

laverdet commented 1 year ago

It will work on nodejs v16.x. The rules about importing JSON files changed in v18.x.

UndefinedCpp commented 1 year ago

I have been running on v16.17.1 already, and so far the issue persists.

bastianh commented 1 year ago

According to Google this was changed in 16.14

UndefinedCpp commented 1 year ago

Okay, this error was solved using nodejs v16.13.2, but another error showed up :(

~/xxscreeps$ node -v
v16.13.2
~/xxscreeps$ npx xxscreeps import

node:internal/process/esm_loader:94
    internalBinding('errors').triggerUncaughtException(
                              ^
Error: Cannot find module './out/x64-linux-v16.13.2/pf.node'
Require stack:
- /home/lighthouse/xxscreeps/src/driver/path-finder/index.cjs
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/lighthouse/xxscreeps/src/driver/path-finder/index.cjs:3:18)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:190:29) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/home/lighthouse/xxscreeps/src/driver/path-finder/index.cjs' ]
}
laverdet commented 1 year ago

You need to delete node_modules and re-run npm install

UndefinedCpp commented 1 year ago

Thank you it works! BTW, maybe we should document using node version <16.14.

laverdet commented 1 year ago

We can leave this open actually in case people come looking for it. The real solution is to add a JSON type assertion which would make node >= 16.14 required. Totally crazy they changed this in a minor point release but I suppose this feature was under an --experimental flag so that's their prerogative.

TylerSeanRau commented 1 year ago

thank you for leaving this open, I was definitely trying to find an answer to this <3