views/index.html, main modification is adding type="module" to the <script> tag:<!DOCTYPE html><html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content="A cool thing made with Glitch"> <title>Welcome to Glitch!</title> <link id="favicon" rel="icon" href="https://glitch.com/edit/favicon-app.ico" type="image/x-icon"> <link rel="stylesheet" href="/style.css"> <script type="module" src="/index.js"></script> </head> <body> </body></html> server.js ,基本上未更改默认值:server.js, basically unmodified from the default:const express = require("express");const app = express();app.use(express.static("public"));app.get("/", (request, response) => { response.sendFile(__dirname + "/views/index.html");});const listener = app.listen(process.env.PORT, () => { console.log("Your app is listening on port " + listener.address().port);}); package.json ,也未更改为默认值:package.json, also unmodified from the default:{ "//1": "describes your app and its dependencies", "//2": "https://docs.npmjs.com/files/package.json", "//3": "updating this file will download and update your packages", "name": "hello-express", "version": "0.0.1", "description": "A simple Node app built on Express, instantly up and running.", "main": "server.js", "scripts": { "start": "node server.js" }, "dependencies": { "express": "^4.17.1" }, "engines": { "node": "12.x" }, "repository": { "url": "https://glitch.com/edit/#!/hello-express" }, "license": "MIT", "keywords": [ "node", "glitch", "express" ]} 这篇关于如何在Glitch中使用静态导入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!