0

I am trying to spin up a local server on my machine in node. I am using the local-web-server package to do so. I have installed the package globally and in my project, however when I run yarn start It was given the following error.
It seems to indicate the CLI for the ws package that local-web-server relies on is not correctly outputting a path. The weird thing is I tried this same setup on a different machine and it worked fine. I have tried uninstalling everything and then reinstalling with no improvement.

yarn run v1.22.15
$ ws
internal/process/esm_loader.js:74
    internalBinding('errors').triggerUncaughtException(
                              ^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/cli-app.mjs' is not defined by "exports" in /Users/name/Documents/Tutorials/local-web-server/node_modules/lws/package.json imported from /Users/name/Documents/Tutorials/local-web-server/node_modules/local-web-server/lib/cli-app.mjs
    at throwExportsNotFound (internal/modules/esm/resolve.js:284:9)
    at packageExportsResolve (internal/modules/esm/resolve.js:490:3)
    at packageResolve (internal/modules/esm/resolve.js:612:14)
    at moduleResolve (internal/modules/esm/resolve.js:664:18)
    at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:778:11)
    at Loader.resolve (internal/modules/esm/loader.js:85:40)
    at Loader.getModuleJob (internal/modules/esm/loader.js:229:28)
    at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:51:40)
    at link (internal/modules/esm/module_job.js:50:36) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Is there something I'm missing here? Why would it build in one environment and not the other?

nima
  • 7,796
  • 12
  • 36
  • 53
kdub1312
  • 803
  • 2
  • 9
  • 19
  • 1
    which OS are you using? – Lloyd Oct 09 '21 at 15:29
  • 1
    also, which version of Node.js are you using? – Lloyd Oct 09 '21 at 15:32
  • @Lloyd I'm on mac OS Big Sur and Node 14.9.0. I'm on a mac with an M1 chip, if that possibly matters – kdub1312 Oct 09 '21 at 15:53
  • 1
    the M1 chip won't matter.. and Node v14 is fine.. i suspect it might be yarn - yarn may lack support for [subpath patterns](https://nodejs.org/api/packages.html#packages_subpath_patterns) used by lws.. – Lloyd Oct 09 '21 at 16:09
  • looking into it now.. i'm the local-web-server maintainer - i will simplify the package.json and get back to you (just in case yarn has issues with it) – Lloyd Oct 09 '21 at 16:11
  • I did intermingle yarn and npm when setting this up- I used npm to globally install local-web-server, then yarn to start the server- does that make any difference? however on the other machine I'm using it 'yarn start' did work fine – kdub1312 Oct 09 '21 at 16:16
  • I don't use `yarn` so unfortunately i don't know about the intermingling.. however, i noticed you have a folder name matching the package name `local-web-server/node_modules/local-web-server` - not sure if that confuses things.. probably not – Lloyd Oct 09 '21 at 16:18
  • i just released a fix - lws no longer uses package export subpatterns.. could you delete your `node_modules`, run `npm install` and try again please? This will pick up the update.. – Lloyd Oct 09 '21 at 16:34

0 Answers0