相关疑难解决方法(0)

Nodemon没有在React-Express-Node App中刷新浏览器

我已在我的工作区中nodemon 本地安装,但即使它在更改后在终端中重新启动,它也不会刷新浏览器页面.我每次都要手动刷新它.

我在环境中运行了Express,Node,React和Webpack.

这就是我的设置看起来像 -

在此输入图像描述

我的package.json开始server.js-

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "nodemon server.js"
  },
Run Code Online (Sandbox Code Playgroud)

server.js- 是 -

var express = require('express');


     var app = express();
        app.use(express.static('public'));
        app.listen(3000, function () {
            console.log("Express server is up on port 3000");
        });
Run Code Online (Sandbox Code Playgroud)

entry point在的WebPack配置文件是-

module.exports = {
    entry: './public/scripts/app.jsx',
    output: {
        path: __dirname,
        filename: './public/scripts/bundle.js'
    }
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能解决这个问题?


更新 -

我做了一个视频来描述情况,如果有帮助的话.

javascript reactjs nodemon webpack

7
推荐指数
2
解决办法
8350
查看次数

试图让无头的WordPress在纱线启动命令上进行热重装

我正在运行这个项目https://github.com/postlight/headless-wp-starter.我已经能够让一切工作达到一定程度.后端工作正常,但是,前端有一个bug.

在说明中它说要运行yarn start以启动前端服务器,应该是next.js.现在技术上工作正常,它继续运行localhost:3000.但是,当我修改scss文件时frontend/src/styles,它不会在shell中重新渲染,并且浏览器中没有热重新加载,即使按下刷新也不会显示样式更改.但是,如果我停止使用纱线,ctrl + c然后再次运行它,yarn start我的样式会显示在浏览器刷新上.

我在docker for Windows下运行所有​​东西,所以不知道这是一个限制,还是可能是一个bug.我已经在他们的github上发布了一个问题,但是认为在这里查看也没有什么坏处.

我能想到的唯一代码是分享package.json它就是这样.提前谢谢.

{
    "name": "frontend",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
        "build": "next build",
        "start": "node server.js",
        "docker:build": "docker build -t frontend .",
        "docker:clean": "docker rm -f frontend || true",
        "docker:run": "docker run -p 3000:3000 --name frontend frontend",
        "docker:stop": "docker stop frontend",
        "docker:start": "docker start frontend && yarn run docker:logs",
        "docker:logs": "docker …
Run Code Online (Sandbox Code Playgroud)

wordpress node.js docker yarnpkg next.js

6
推荐指数
1
解决办法
323
查看次数

如何在 Node.js 和 npm 安装后运行实时服务器

我使用的是 Windows 10,并且在我的本地机器上安装了 Node.js(带有 npm)。我正在尝试遵循以下说明:

"Once node.js and npm are installed, run the following command in your terminal.

npm install -g live-server

This will install live-server?, a simple static server that has live reload built-in. To
start your server, run live-server in your terminal from the root /code folder —
it will even open a new browser window for you!"
Run Code Online (Sandbox Code Playgroud)

由于我在 Windows 上,我猜“终端”的意思是“命令提示符”。所以,我已经npm install -g live-server从 C:// 提示符运行了“ ”。

我现在对它说“live-server从根 /code 文件夹在您的终端中运行”的部分感到困惑。

是什么root /code folder …

node.js npm npm-live-server

4
推荐指数
2
解决办法
2万
查看次数