forcedotcom / lwc-dev-server-feedback

LWC Local Development
BSD 3-Clause "New" or "Revised" License
45 stars 10 forks source link

Error when starting local dev server. #39

Closed sgriner closed 4 years ago

sgriner commented 4 years ago

Summary

Unable to start local dev server.

Steps To Reproduce:

  1. Install lwc-dev-server plugin.
  2. Clone lwc-recipes.git
  3. Configure DevHub.
  4. Create scratch org and push up code.
  5. Start local dev server.

Expected result

Local dev server should start on port 3333.

Actual result

Starting LWC Local Development.
    Dev Hub Org: DevHub
    Scratch Org: test-r7vvkiqrryt5@example.com
    Api Version: 47.0
unhandledPromiseRejection: Error: Unable to start LocalDevServer: Error: modulePaths is not a directory: /Users/xxxx/.local/share/sfdx/client/7.30.13-9e204762d5/bin/node

VS Code Version: 1.39.2

SFDX CLI Version: sfdx-cli/7.30.13-9e204762d5 darwin-x64 node-v10.15.3

OS and version: macOS 10.15.1

mysticflute commented 4 years ago

Did you add any configuration for the local dev server, such as localdevserver.config.json?

sgriner commented 4 years ago

No. I just did a clone from the lwc-recipes repository, and didn't change anything.

gdman commented 4 years ago

I have the same issue whilst trying to start the local dev server.

Version: 7.41.0-2a5f766389 / macOS: 10.15.1

I've done a bit of digging and from what I can tell this is a bug in the plugin. modulePaths is built using require.resolve.paths('.'), this returns various directories but can also return the node binary - the node binary is not a directory hence the error. There is a check that the various modulePaths exist but not that they are a directory.

Obviously, I wouldn't advocate making changes to files in node_modules or dist files because we all know thats a terrible idea for so many reasons. However, if you were to want a quick hack just to get the local dev server up and running to have a play around (whilst the Salesforce dev team apply a proper fix)... the file to look in is: ~/.local/share/sfdx/node_modules/@salesforce/lwc-dev-server/dist/server/LocalDevServer.js.

I added the following line: modulePaths = modulePaths.filter(path => fs_1.default.lstatSync(path).isDirectory()); below: modulePaths = modulePaths.filter(fs_1.default.existsSync); (in the 'start' method)

All it does is filters out any module paths that are not directories.

sgriner commented 4 years ago

Thanks @gdman! That works great, as a temporary workaround.

KrisGraySFDC commented 4 years ago

Thanks guys, we've filed a work item for this W-7151906 and will pick it up soon.

stale[bot] commented 4 years ago

This issue has been automatically marked as type:bug-p3 because it has not had recent activity.

jag-j commented 4 years ago

@sgriner @gdman - The latest lwc-dev-server version (2.1.0) fixes this. Thanks for reporting the issue!