Gulp watch error Error: watch /home/react-mobile/stylus/ ENOSPC

 'watch' errored after 19 ms
[13:25:21] Error: watch /home/react-mobile/stylus/ ENOSPC
    at exports._errnoException (util.js:870:11)
    at FSWatcher.start (fs.js:1234:19)
    at Object.fs.watch (fs.js:1262:11)
    at Gaze._watchDir (/home/react-mobile/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:289:30)
    at /home/react-mobile/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:358:10
    at iterate (/home/react-mobile/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/helper.js:52:5)
    at Object.forEachSeries (/home/react-mobile/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/helper.js:66:3)
    at Gaze._initWatched (/home/react-mobile/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:354:10)
    at Gaze.add (/home/react-mobile/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:177:8)
    at new Gaze (/home/react-mobile/node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-watcher/node_modules/gaze/lib/gaze.js:74:10)

 

报错原因是由于Linux watch文件大小限制

 

解决方案:修改watch限制

 

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

 

 



有疑问或技术交流,扫描公众号一起讨论学习。

更多React在线学习访问:http://each.sinaapp.com/react/index.html

在使用 Vite 启动预览服务器时,如果提示 `'dist'` 目录不存在,通常是因为尚未执行构建操作,导致预览服务器无法找到输出文件夹。Vite 的 `preview` 命令依赖于 `dist` 目录中的构建文件来提供静态资源服务,因此在运行 `vite preview` 命令前,必须先执行构建命令生成该目录。 确保在执行预览命令之前已经运行了构建命令,例如: ```bash vite build ``` 构建完成后,再运行以下命令启动预览服务器: ```bash vite preview ``` 如果仍然提示目录不存在,可能是因为构建过程中出现错误,或者构建输出路径配置不正确。检查 `vite.config.js` 文件中的 `build.outDir` 配置项是否正确设置为 `dist`,默认配置如下: ```javascript export default defineConfig({ build: { outDir: 'dist', // 默认值为 'dist' }, }); ``` 若构建路径被自定义为其他目录,需要确保在运行 `vite preview` 时指定相同的输出目录,或者修改配置文件以保持一致性。 此外,某些情况下可能会遇到构建完成后 `dist` 目录被意外删除或未正确生成的问题,可以手动检查文件系统确认目录是否存在,或在构建完成后添加清理逻辑以避免目录冲突。例如使用 Gulp 等工具进行自动化构建和清理操作时,需确保清理任务不会误删构建输出目录,可以参考以下 Gulp 任务示例来安全清理 `dist` 文件夹: ```javascript const { task, src, dest, watch, series, parallel } = require('gulp'); const del = require('del'); task('clean:dist', function (cb) { del(['dist/']).then(paths => { console.log(paths); cb(); }); }); ``` 通过以上方式可以确保构建流程顺利执行,并在构建完成后正确生成 `dist` 目录,从而解决 Vite 预览服务器提示目录不存在的问题[^4]。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值