reactjs - 收到以下错误无法读取未定义的属性“startsWith”
问题描述
在 laravel 8 上安装带有惯性 js 的反应后。运行“npm run dev”时出现以下错误
PS D:\Projects\Inertiajs with react and laravel\project> npm run dev
> @ dev D:\Projects\Inertiajs with react and laravel\project
> npm run development
> @ development D:\Projects\Inertiajs with react and laravel\project
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js
98% after emitting SizeLimitsPlugin
ERROR Failed to compile with 4 errors 6:35:46 PM
TypeError: Cannot read property 'startsWith' of undefined
at isRelative (D:\Projects\Inertiajs with react and laravel\project\node_modules\friendly-errors-webpack-plugin\src\formatters\moduleNotFound.js:5:17)
解决方案
我在尝试在 laravel 8 上安装惯性/反应时遇到了同样的问题。我通过将 Pages 文件夹添加到 laravel 项目中的资源/js 来修复错误。发生这种情况是因为遵循惯性文档,您参考
resolveComponent={name => require(
./Pages/${name}
).default}
在 app.js 渲染函数中,但该文件夹在您创建它之前不存在。祝你好运!
推荐阅读
- sql-server - 更新 SSAS 多维数据集中的缺失数据
- google-sheets - 哪个 VLOOKUP 公式更优化性能?包含多个不需要的列的范围,或仅包含搜索键和单列范围的数组
- google-sheets - ImportHTML (nasdaq.com) 给出:“错误:无法获取 URL。”
- ros - 用于 ROS 的 Universal Robot Driver 问题
- tfs - 从 Azure Dev Ops 执行增强的测试套件导出时加载 dataTFS.WebApi.Exception 时出错
- azure - Azure Devops 无法禁用“新服务连接体验”
- azure - Azure Function 在执行期间关闭
- turing-machines - TOC 程序 A,当给定任何程序 B 作为输入时,可以确定 B 是否产生“hello world”
- docker - Docker compose env 变量未替换
- r - 根据数据框的名称列出数据框(按名称调用数据框)