npm - gatsby develop 显示错误“TypeError:预期模式为非空字符串”
问题描述
当我运行gatsby develop
错误发生
D:\[Web dev]\gatsby-test\my-gatsby-project>gatsby develop
info Cache exists but contains no nodes. There should be at least some nodes available so it seems the cache was corrupted. Disregarding the cache and proceeding as if there was none.
success open and validate gatsby-configs, load plugins - 0.600s
success onPreInit - 0.025s
success initialize cache - 0.016s
⠋ copy gatsby files
C:\Users\sayee\AppData\Roaming\npm\node_modules\gatsby-cli\node_modules\yoga-layout-prebuilt\yoga-layout\build\Release\nbind.js:53
throw ex;
^
TypeError: Expected pattern to be a non-empty string
at picomatch (D:\[Web dev]\gatsby-test\my-gatsby-project\node_modules\picomatch\lib\picomatch.js:48:11)
at createPattern (D:\[Web dev]\gatsby-test\my-gatsby-project\node_modules\anymatch\index.js:27:18)
at D:\[Web dev]\gatsby-test\my-gatsby-project\node_modules\anymatch\index.js:91:21
at Array.map (<anonymous>)
at anymatch (D:\[Web dev]\gatsby-test\my-gatsby-project\node_modules\anymatch\index.js:91:6)
at D:\[Web dev]\gatsby-test\my-gatsby-project\node_modules\chokidar\index.js:272:51
at Array.every (<anonymous>)
at D:\[Web dev]\gatsby-test\my-gatsby-project\node_modules\chokidar\index.js:270:22
at Array.some (<anonymous>)
at WatchHelper.filterDir (D:\[Web dev]\gatsby-test\my-gatsby-project\node_modules\chokidar\index.js:269:43)
Emitted 'error' event on FSWatcher instance at:
at FSWatcher._handleError (D:\[Web dev]\gatsby-test\my-gatsby-project\node_modules\chokidar\index.js:647:10)
at ReaddirpStream.NodeFsHandler._boundHandleError (D:\[Web dev]\gatsby-test\my-gatsby-project\node_modules\chokidar\lib\nodefs-handler.js:303:43)
at ReaddirpStream.emit (events.js:375:28)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
但是gatsby build
两者gatsby serve
都可以正常工作。
我什至还没有开始在其中添加任何新文件或代码。我只是使用了 gatsby 启动器(我也尝试使用不同的启动器)
gatsby new my-hello-world-starter https://github.com/gatsbyjs/gatsby-starter-hello-world
我还创建了 gatsbynpm init gatsby
仍然有同样的错误
这是 package.json 文件
{
"name": "gatsby-starter-hello-world",
"private": true,
"description": "A simplified bare-bones starter for Gatsby",
"version": "0.1.0",
"license": "0BSD",
"scripts": {
"build": "gatsby build",
"develop": "gatsby develop",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"",
"start": "npm run develop",
"serve": "gatsby serve",
"clean": "gatsby clean",
"test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1"
},
"dependencies": {
"gatsby": "^3.10.2",
"react": "^17.0.1",
"react-dom": "^17.0.1"
},
"devDependencies": {
"prettier": "2.3.2"
},
"repository": {
"type": "git",
"url": "https://github.com/gatsbyjs/gatsby-starter-hello-world"
},
"bugs": {
"url": "https://github.com/gatsbyjs/gatsby/issues"
}
}
我在用
node:14.17.1
npm:6.14.14 (i also tried npm:7.1x.x)
gatsby-cli:3.10.2
我尝试了几次删除缓存,删除 node_modules 和 package-lock.json 文件并重新安装依赖项npm install
解决方案
推荐阅读
- aws-lambda - 无服务器 - 类型错误:无法读取未定义的属性“属性”
- javascript - 在打字稿中输入 args
- python - 如何为列表中的每个列表创建一个新列
- arduino - 我可以在 Arduino Mega 中临时存储 16 位卡号及其 4 位密码吗?
- kotlin - Kotlin 的 Listview 中显示两个 ArrayList
- javascript - Webpack polyFill - 无法读取未定义的属性“信号”
- android - SmoothScroll 到 recyclerview 的最后一项有时不起作用
- javascript - javascripto 或 jquery 打开弹出窗口,而不会失去所有浏览器中当前选项卡的焦点
- opencv - Caffe detection_evaluate_layer.cpp:56] 检查失败:bottom[1]->num() == 1 (8 vs. 1)
- math - 从 2 点、圆弧角和平面法线计算圆心 (3D)