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

feat: migrate to Vite, support Node LTS (v18) #49

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

cloydlau
Copy link

@cloydlau cloydlau commented Oct 8, 2023

When I run build under Node LTS, it throws 'Error: error:0308010C:digital envelope routines::unsupported'
I think it's time to migrate from webpack to Vite, it reduces devDependency count from 18 to 1.
Node LTS passing.

@kamiljune
Copy link

npm run dev 模式跑不起来,应该是 package.json 没配置 dev,俺好多年没写代码了,还没搞定。。。

@cloydlau
Copy link
Author

cloydlau commented Dec 8, 2023

@kamiljune 用我的仓库:https://github.com/cloydlau/lottery

@kamiljune
Copy link

@kamiljune 用我的仓库:https://github.com/cloydlau/lottery

你好,我试了下你的仓库执行 npm run dev 还是报错:

npm ERR! Missing script: "dev"  
npm ERR!  
npm ERR! To see a list of scripts, run:  
npm ERR!   npm run

看着是 package.json 里没有定义dev(如图),我试了下增加 dev 和 vite.dev.js 还是不行,目测后端没有拉起来。
Dingtalk_20231212155902

package.json 配置如下:

"scripts": {
    "start": "npm run build && cd dist && node ../../server/index.js 8888",
    "serve": "vite --open",
    "build": "vite build",
    "dev": "vite --config vite.dev.js"
  },

vite..dev.js 配置如下:

import { defineConfig } from "vite";

export default defineConfig({
  mode: "development",
  server: {
    hot: true,
    compress: true,
    port: 9000,
    open: true,
    proxy: {
      "*": "http://localhost:18888"
    },
    after: async (server) => {
      // 启动后端服务
      const app = express();
      app.get("/", (req, res) => res.send("Hello, world!"));
      app.listen(18888);
    }
  }
});

@kamiljune 用我的仓库:https://github.com/cloydlau/lottery

@cloydlau
Copy link
Author

@kamiljune 我试了可以正常运行没问题。我的环境是 node lts + pnpm lts

  1. 前端后端的目录都把依赖装好
  2. 前端目录跑 pnpm run start

@kamiljune
Copy link

start 模式没问题哈,dev 不行,算了我不用 dev 了,反正差不多,感谢😂

@kamiljune 我试了可以正常运行没问题。我的环境是 node lts + pnpm lts

  1. 前端后端的目录都把依赖装好
  2. 前端目录跑 pnpm run start

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants