我是 Node.js 的新程序员。我尝试在 Node.js 中创建普通服务器。在我的客户端中,我使用了 ES6 模块。当我启动服务器并在浏览器中搜索 http://localhost:3000/ 时,加载了 HTML 和 CSS,但对于 javascript 有此错误:
我有四个用于客户端的 javascript 模块,在 HTML 中我使用此代码来加载 javascript 模块:
<script type="module" src="js/controller.js" async></script>
Run Code Online (Sandbox Code Playgroud)
我的服务器代码:
const http = require('http');
const fs = require('fs');
const path = require('path');
const PORT = 3000;
const server = http.createServer();
server.on('request', (req, res) => {
let routes = {
'GET': {
'/': indexHtml,
}
}
console.log(req.url)
let handler = routes[req.method][req.url];
handler = handler || readFile;
handler(req, res);
})
server.listen(PORT, () => {
console.log(`Listening on …Run Code Online (Sandbox Code Playgroud) 我的 Dockerized Django 应用程序遇到问题。我正在使用以下 Dockerfile 来构建我的应用程序:
FROM python:alpine
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV DJANGO_SUPERUSER_PASSWORD datahub
RUN mkdir app
WORKDIR /app
COPY ./app .
RUN mkdir -p volumes
RUN apk update
RUN apk add --no-cache gcc python3-dev musl-dev mariadb-dev
RUN pip3 install --upgrade pip
RUN pip3 install -r requirements.txt
RUN apk del gcc python3-dev musl-dev
CMD python3 manage.py makemigrations --noinput &&\
while ! python3 manage.py migrate --noinput; do sleep 1; done && \
python3 manage.py collectstatic --noinput &&\
python3 …Run Code Online (Sandbox Code Playgroud)