gpt4 book ai didi

javascript - 数据关闭时 npm run watch 无法编译

转载 作者:行者123 更新时间:2023-12-02 23:58:02 24 4
gpt4 key购买 nike

我正在使用 Laravel 并使用大量 Node 包进行开发。但我遇到的问题是我的互联网连接有限。

因此,每当我运行 npm run watch 时,它都不会启动,直到我连接到互联网,并且几个小时后,如果我关闭数据连接,它将停止编译。我在 Windows 机器上。

我的问题是,我可以做些什么以使编译可以在离线模式下工作吗?

还是我做错了什么?我目前正在开发 laravel 5.8

下面是我的package.json

{
"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": "npm run development -- --watch",
"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 --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"axios": "^0.18",
"bootstrap": "^4.0.0",
"cross-env": "^5.1",
"jquery": "^3.2",
"laravel-mix": "^4.0.7",
"lodash": "^4.17.5",
"popper.js": "^1.12",
"resolve-url-loader": "^2.3.1",
"sass": "^1.15.2",
"sass-loader": "^7.1.0",
"vue": "^2.5.17",
"vue-template-compiler": "^2.6.10"
},
"dependencies": {
"@fortawesome/fontawesome-free": "^5.8.0",
"admin-lte": "^3.0.0-alpha.2"
}
}

最佳答案

这是一个在线版本,但您可以将此脚本添加到package.json文件中

"watch": "webpack --watch --modedevelopment",

这样您就可以在执行过程中避免不必要的资源和操作。它看起来像这样:

{
"name": "watch",
"version": "1.0.0",
"description": "",
"main": "webpack.config.js",
"scripts": {
"watch": "webpack --watch --mode development",
"build": "webpack --mode production"
},
"author": "",
"license": "ISC",
"devDependencies": {
"webpack": "^4.16.5",
"webpack-cli": "^3.1.0"
}
}

有关更多信息,请参阅: https://jscraftsman.com/2018/08/15/setting-up-the-javascript-development-environment/

https://gist.github.com/jscraftsman/17f968a26340b01176ee71a724bcb914#file-package-json

https://blog.fellyph.com.br/javascript/webpack-mantendo-a-qualidade-do-seu-javascript/

关于javascript - 数据关闭时 npm run watch 无法编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55290461/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com