Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ERROR] Could not resolve "ws" #612

Open
hopezh opened this issue May 5, 2024 · 6 comments
Open

[ERROR] Could not resolve "ws" #612

hopezh opened this issue May 5, 2024 · 6 comments
Labels
bug Something isn't working js

Comments

@hopezh
Copy link

hopezh commented May 5, 2024

I got the following error while running the example code rhino3dm.js.

I don't know how to ...mark the path "ws" as external to exclude it from the bundle, as suggested in the error message.

May I ask if I have missed something important here?

npm run dev

> threejs_starter_v01@0.0.0 dev
> vite

  VITE v5.2.8  ready in 169 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: http://192.168.138.1:5173/
  ➜  Network: http://192.168.70.1:5173/
  ➜  Network: http://192.168.12.121:5173/
  ➜  press h + enter to show help

✘ [ERROR] Could not resolve "ws"

    node_modules/rhino3dm/rhino3dm.js:9:64363:
      9 │ ...ocketServer=require("ws").Server;var host=so...
        ╵                        ~~~~

  You can mark the path "ws" as external to exclude it from
  the bundle, which will remove this error and leave the
  unresolved path in the bundle. You can also surround this
  "require" call with a try/catch block to handle this
  failure at run-time instead of bundle-time.

6:16:26 pm [vite] error while updating dependencies:
Error: Build failed with 1 error:
node_modules/rhino3dm/rhino3dm.js:9:64363: ERROR: Could not resolve "ws"
    at failureErrorWithLog (C:\Users\aaa\Downloads\code\threejs_starter_v01\node_modules\esbuild\lib\main.js:1651:15)
    at C:\Users\aaa\Downloads\code\threejs_starter_v01\node_modules\esbuild\lib\main.js:1059:25
    at C:\Users\aaa\Downloads\code\threejs_starter_v01\node_modules\esbuild\lib\main.js:1527:9
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

The output of my npm list:

+-- rhino3dm@8.6.0
+-- three@0.163.0
`-- vite@5.2.8
@fraguada
Copy link
Member

fraguada commented May 9, 2024

Please try with rhino3dm@8.4.0 as there is an issue with 8.6.0. I've since deprecated 8.6.0 and made 8.4.0 latest.

@fraguada fraguada added bug Something isn't working js labels May 9, 2024
@fraguada
Copy link
Member

fraguada commented May 9, 2024

I am preparing an 8.6.1 release for js. If you can test this package, I would really appreciate it: https://github.com/mcneel/rhino3dm/actions/runs/9017758138/artifacts/1487757185

@fraguada fraguada mentioned this issue May 9, 2024
@fraguada
Copy link
Member

https://www.npmjs.com/package/rhino3dm/v/8.6.1 has been published which should resolve this issue. Please let me know if that is not the case.

@hopezh
Copy link
Author

hopezh commented May 10, 2024

Thanks, @fraguada.

I still got the following error while running the example code on the latest npm repo of rhino3dm, and the test code is in this repo.

(BTW, I init the test repo with npm create vite@latest.)

Error

npm run dev

> test_rhino3dm_js@0.0.0 dev
> vite


  VITE v5.2.11  ready in 217 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help
✘ [ERROR] Could not resolve "ws"

    node_modules/rhino3dm/rhino3dm.js:9:64363:
      9 │ ...r(26)},listen:function(sock,backlog){if(!ENVIRONMENT_IS_NODE){throw new FS.ErrnoError(138)}if(sock.server){throw new FS.ErrnoError(28)}var WebSocketServer=require("ws").Server;var host=sock.saddr;sock.server=new WebSocketServer({host:host,port:sock.sport});Module["websocket"].emit("listen",sock.stream.fd);sock.server.on("connec...
        ╵                                                                                                                                                                       ~~~~

  You can mark the path "ws" as external to exclude it from the bundle, which will remove this error
  and leave the unresolved path in the bundle. You can also surround this "require" call with a
  try/catch block to handle this failure at run-time instead of bundle-time.

my npm list:

> npm list

test_rhino3dm_js@0.0.0 C:\Users\jizha\Downloads\code\test_rhino3dm_js
+-- rhino3dm@8.6.1
`-- vite@5.2.11

@fraguada
Copy link
Member

Unfortunately I don't know anything about vite, so don't know how to help. I'll try running vite to see if I can figure out the issue.

@fraguada fraguada reopened this May 13, 2024
@jdev-chicago
Copy link

any updates on this issue? I'm running into the same error. vite@latest : Typescript+SWC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working js
Projects
None yet
Development

No branches or pull requests

3 participants