在Debian上使用JavaScript框架(如Node.js、React和Vue.js)构建应用是一个相对直接的过程。以下是针对不同框架的详细步骤指南:
sudo apt update
sudo apt upgrade -y
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt install -y nodejs
mkdir my-api
cd my-api
npm init -y
npm install express --save
server.js
的文件,并添加以下代码:const express = require('express');
const app = express();
const port = 3000;
app.get('/', (req, res) => {
res.send('Hello World!');
});
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});
node server.js
http://localhost:3000
,你应该会看到“Hello World!”的响应。curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs
npx create-react-app my-react-app
cd my-react-app
npm start
http://localhost:3000
查看应用。sudo apt update
sudo apt install nodejs npm
sudo npm install -g @vue/cli
vue create my-vue-project
cd my-vue-project
npm run serve
http://localhost:8080
查看应用。以上步骤涵盖了在Debian上使用Node.js、React和Vue.js框架构建应用的基本流程。根据具体需求,你可以进一步安装其他相关工具和库来扩展应用的功能。