简体   繁体   English

Laravel - npm run watch - 反复运行 - 不停

[英]Laravel - npm run watch - runs repeatedly - nonstop

I have installed Laravel.我已经安装了 Laravel。 I use the Visual Studio Code to develop on my Windows 10. I have installed the npm and node.我使用 Visual Studio Code 在我的 Windows 10 上进行开发。我已经安装了 npm 和 node。 And ran install based on Laravel's default package.json , using npm install command.并使用npm install命令基于 Laravel 的默认package.json npm install I kept the file unchanged, and it looks like this:我保持文件不变,它看起来像这样:

{
  "private": true,
  "scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch-poll": "npm run watch -- --watch-poll",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "axios": "^0.15.3",
    "bootstrap-sass": "^3.3.7",
    "cross-env": "^3.2.3",
    "jquery": "^3.1.1",
    "laravel-mix": "0.*",
    "lodash": "^4.17.4",
    "vue": "^2.1.10"
  }
}

The problem is, that running npm run watch , does not just make the npm wait for changes.问题是,运行npm run watch不仅仅是让 npm 等待更改。 npm runs the npm run dev all the time, over and over again! npm 一直运行npm run dev ,一遍又一遍!

The proper answer to this issue was addressed here此问题的正确答案已在此处解决

https://github.com/JeffreyWay/laravel-mix/issues/228 https://github.com/JeffreyWay/laravel-mix/issues/228

It also has solution to resolve it and what causes it.它还具有解决它的解决方案以及导致它的原因。

i had same issue and it's because i placed my image into public/images directory and this path was loading into my sass file.我遇到了同样的问题,这是因为我将图像放入public/images目录中,并且此路径正在加载到我的 sass 文件中。 when i changed image path , that's worked fine当我更改图像路径时,效果很好

This issue happen's when you placed your assets into build path.当您将资产放入构建路径时会发生此问题。

npm run watch constantly running. npm run watch 不断运行。 Normal?普通的? yes its normal是的,这是正常的

use npm run development instead of npm run watch使用npm run development而不是npm run watch

npm run watch used for tracking your changes in css and js files then deploy it immediately npm run watch用于跟踪您在 css 和 js 文件中的更改,然后立即部署它

but npm run development deploy it once for development and npm run production for production (minified files)但是npm run developmentnpm run development部署一次,为生产部署npm run production production(缩小文件)

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

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