JairusSW / as-json

The only JSON library you'll need for AssemblyScript. SIMD enabled
MIT License
79 stars 15 forks source link

Error ... Cannot find package 'visitor-as' #50

Open mattjohnsonpint opened 1 year ago

mattjohnsonpint commented 1 year ago

Steps to reproduce:


FAILURE Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'visitor-as' imported from /<projectdir>/node_modules/json-as/transform/lib/index.js
    at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
    at new NodeError (node:internal/errors:405:5)
    at packageResolve (node:internal/modules/esm/resolve:890:9)
    at moduleResolve (node:internal/modules/esm/resolve:939:20)
    at defaultResolve (node:internal/modules/esm/resolve:1132:11)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:835:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
    at link (node:internal/modules/esm/module_job:76:36)

Tried manually installing with npm install visitor-as --save-dev, but that gives:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: astmp@1.0.0
npm ERR! Found: assemblyscript@0.27.14
npm ERR! node_modules/assemblyscript
npm ERR!   dev assemblyscript@"^0.27.14" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer assemblyscript@"^0.25.0" from visitor-as@0.11.4
npm ERR! node_modules/visitor-as
npm ERR!   dev visitor-as@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

It does work if I use --force, but I shouldn't have to do that.

Not sure if this is a problem with as-json, or with visitor-as, or both.

Thanks.

mattjohnsonpint commented 1 year ago

To clarify, if I use --force or --legacy-peer-deps, it adds visitor-as to the devDependencies section correctly, but future calls to npm install (such as on a fresh clone of my project repo) still fail with the same message.

As a workaround, this seems to do the trick:

{
 "dependencies": {
     "json-as": "^0.5.65"
  },
  "devDependencies": {
    "assemblyscript": "^0.27.14",
    "visitor-as": "^0.11.4"
  },
  "overrides": {
    "assemblyscript": "$assemblyscript"
  }
}

With that override, now my npm install works without giving an error.

JairusSW commented 1 year ago

Got it. Yeah that's just how NPM works sometimes and is a problem with visitor-as' deps