简体   繁体   English

npm run build 不更新反应组件

[英]npm run build does not update the react components

i have a react project with the following package.json :我有一个带有以下 package.json 的反应项目:

    {
  "name": "commonsensev2.0",
  "version": "0.1.0",
  "private": true,
  "homepage": "http://localhost:9080/server/react",
  "dependencies": {
    "all": "0.0.0",
    "axios": "^0.18.0",
    "babel-polyfill": "^6.26.0",
    "chart.js": "^2.7.3",
    "moment": "^2.23.0",
    "node-sass-chokidar": "0.0.3",
    "npm-run-all": "^4.1.5",
    "popper.js": "^1.14.6",
    "react": "^16.7.0",
    "react-bootstrap": "^0.31.5",
    "react-bootstrap-table": "^4.3.1",
    "react-chartjs2": "^1.2.1",
    "react-dom": "^16.7.0",
    "react-localize-redux": "^2.17.5",
    "react-moment": "^0.7.9",
    "react-redux": "^5.1.1",
    "react-router-dom": "^4.3.1",
    "react-scripts": "1.0.14",
    "redux": "^3.7.2"
  },
  "scripts": {
    "build-css": "node-sass-chokidar src/sass/App.scss -o src/css/",
    "watch-css": "npm run build-css && node-sass-chokidar src/sass/App.scss -o src/css/ --watch --recursive",
    "start-js": "react-scripts start",
    "start": "npm-run-all -p watch-css start-js",
    "build": "npm run build-css && react-scripts build",
    "postbuild": "((ROBOCOPY build ../react /MIR) ^& if %ERRORLEVEL% lss 8 set ERRORLEVEL = 0)",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "devDependencies": {
    "bootstrap-toggle": "^2.2.2",
    "datatables.net": "^1.10.19",
    "numeral": "^2.0.6"
  }
}

when i do npm run build i cannot see the changes on the html pages, im using node 8.11.1 i downgraded it because i found somewhere that it maybe the reason why it does not work i'm also using "node-sass-chokidar": "0.0.3" and the backend is a java server当我执行 npm run build 时,我看不到 html 页面上的更改,我使用节点 8.11.1 我将其降级,因为我发现某处可能是它不起作用的原因我也在使用“node-sass-chokidar ":"0.0.3" 后端是一个java服务器

我遇到了同样的问题,我删除了本地环境中的旧 build 文件夹,然后再次运行npm run build以生成一个新的 build 文件夹。

Just a wild guess here but I think you are running the wrong command.这里只是一个疯狂的猜测,但我认为您运行了错误的命令。 Because build is typically when you want to build code for a purpose like putting it on a server.因为build通常是为了将代码放在服务器上等目的而构建代码。

What you need to do is to npm run start , as that has the watch , that watches for changes and updates.你需要做的是npm run start ,因为它有watch ,它watch变化和更新。

Just a minor thing, I would rename the start script to dev or serve .只是一件小事,我会将start脚本重命名为devserve Generally more used I would say.一般比较常用我会说。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM