在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框架構建應用的基本流程。根據具體需求,你可以進一步安裝其他相關工具和庫來擴展應用的功能。