开箱Astro前端框架及端口配置

前端开发Astro 444

前端技术发展的就是这么快,VueNextJS刚弄明白,今天刚了解到这个非常优秀的全新前端框架,先说下安装遇到的问题

安装问题

安装方法都在这里:https://docs.astro.build/zh-cn/install/auto/

但是我在用yarn create astro安装遇到个问题

yarn create v1.21.0
[1/4] Resolving packages...
[2/4] Fetching packages...
error create-strapi[email protected]: The engine "node" is incompatible with this module. Expected version ">=10.16.0 <=14.x.x". Got "16.15.1"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.

这时候千万别去动nodejs的注意,用npm安装即可,只需要输入

npm create astro@latest

端口问题

本地端口如果被占用需要修改端口则需要修改文件astro.config.mjs,在export default defineConfig中加入

server: { port: 8882, host: true}

最后重新启动服务即可。

常用命令

安装tailwind插件

yarn astro add tailwind

react的支持

yarn astro add react

启动应用

npm run dev

编译成静态文件

yarn build

预览静态文件

yarn preview

Post Comment