vue.js - Nuxt.js:fsevents 不是构造函数
问题描述
我正在使用 MacOS Mojave 10.14.5。当我在 nuxt 启动程序包所在的位置运行“npm run dev”命令时,出现“fsevents”错误,并且服务器无法工作。
我已经多次重新安装 node 和 npm,但它不起作用。
这是一个错误:
/Users/kimgyun/Desktop/nuxt_test_folder/nuxt_test_b/node_modules/watchpack/node_modules/chokidar/lib/fsevents-handler.js:28
return (new fsevents(path)).on('fsevent', callback).start();
^
TypeError: fsevents is not a constructor
at createFSEventsInstance (/Users/kimgyun/Desktop/nuxt_test_folder/nuxt_test_b/node_modules/watchpack/node_modules/chokidar/lib/fsevents-handler.js:28:11)
at setFSEventsListener (/Users/kimgyun/Desktop/nuxt_test_folder/nuxt_test_b/node_modules/watchpack/node_modules/chokidar/lib/fsevents-handler.js:82:16)
at FSWatcher.FsEventsHandler._watchWithFsEvents (/Users/kimgyun/Desktop/nuxt_test_folder/nuxt_test_b/node_modules/watchpack/node_modules/chokidar/lib/fsevents-handler.js:252:16)
at FSWatcher.<anonymous> (/Users/kimgyun/Desktop/nuxt_test_folder/nuxt_test_b/node_modules/watchpack/node_modules/chokidar/lib/fsevents-handler.js:386:25)
at LOOP (fs.js:1570:14)
at process._tickCallback (internal/process/next_tick.js:61:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nuxt_test_b@1.0.0 dev: `nuxt`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nuxt_test_b@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/kimgyun/.npm/_logs/2019-06-06T02_11_18_374Z-debug.log
如何在没有此错误的情况下运行此 nuxt.js 服务器?
解决方案
这是 fs 事件的一个问题,而且是一个相当烦人的问题。具体来说,当您使用 Node 12 时会发生这种情况。
您需要明确安装 fsevents@1.2.9:
npm i fsevents@1.2.9 -D
或者
yarn add fsevents@1.2.9 -D
这应该对你有用。
推荐阅读
- c - 如何将列表的两个元素复制到一个更大的元素中?
- javascript - 使用 PHP 在 html 视频标签中获取安全 url
- java - com.google.android.gms.common.internal.zzf 类型被引用为来自 `com.google.android.gms.internal.zzcku` 的接口
- php - 如何按降序对数组的值进行排序
- git - git-checkout 的非确定性行为
- python - 我可以在 Flask 服务器启动之外调用控制器吗?
- sql - 协助 SQL Server 中的百分比计算
- amazon-web-services - 将现有 EC2 实例导出到 CloudFormation json/yaml
- swiftui - 防止视图超出屏幕宽度
- amazon-web-services - AWS Lambda 代理 - 客户端未接收标头