Solve Error: Cannot find module 'node:url', and Network: use --host to expose cannot access services through network IP

Error: Cannot find module 'node:url' is reported when running the Vue3 code, which means there is a problem with the version of node

You can use nvm to manage the node version

Since the node version of this project on git requires 15+

Use nvm list available to view available node versions

Use nvm install xx.xx.xx to install the node version,

Use nvm use xx.xx.xx to use node version

It will be normal when you run the project again

At this time, the LAN is not open: Network: use --host to expose

There are the following workarounds:

Method 1: Modify the npm script in package.json and add --host 0.0.0.0

Method Two:

Configure server.host in vite.config.js

Method 3: vite cli configuration, execute npx vite --host 0.0.0.0 command

Guess you like

Origin blog.csdn.net/weixin_42627850/article/details/129313519