创建 React App:范围错误 - 超出最大调用堆栈大小

IT技术 reactjs create-react-app controlled-folder-access
2021-05-12 04:21:45

尝试创建新的 React 应用程序时出现此错误。尝试使用 npm 更新 create-react-app 并重新安装 React。

C:\Users\Panduka\Documents\tests>create-react-app markdown
path.js:33
function normalizeStringWin32(path, allowAboveRoot) {
                             ^

RangeError: Maximum call stack size exceeded
    at normalizeStringWin32 (path.js:33:30)
    at Object.resolve (path.js:338:20)
    at getRootPath (C:\Users\Panduka\AppData\Roaming\npm\node_modules\create-react-app\node_modules\fs-extra\lib\mkdirs\win32.js:6:27)
    at invalidWin32Path (C:\Users\Panduka\AppData\Roaming\npm\node_modules\create-react-app\node_modules\fs-extra\lib\mkdirs\win32.js:16:12)
    at mkdirsSync (C:\Users\Panduka\AppData\Roaming\npm\node_modules\create-react-app\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:15:39)
    at mkdirsSync (C:\Users\Panduka\AppData\Roaming\npm\node_modules\create-react-app\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:35:16)
    at mkdirsSync (C:\Users\Panduka\AppData\Roaming\npm\node_modules\create-react-app\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:36:9)
    at mkdirsSync (C:\Users\Panduka\AppData\Roaming\npm\node_modules\create-react-app\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:36:9)
    at mkdirsSync (C:\Users\Panduka\AppData\Roaming\npm\node_modules\create-react-app\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:36:9)
    at mkdirsSync (C:\Users\Panduka\AppData\Roaming\npm\node_modules\create-react-app\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:36:9)
4个回答

通过禁用 Windows Defender - 受控文件夹访问解决了此问题。

我今天遇到了类似的问题并通过运行修复: $ npm logout

错误日志:

4268 http fetch GET 404 https://registry.npmjs.org/@xtuc%2flong 549ms
4269 silly fetchPackageMetaData error for @xtuc/long@4.2.1 404 Not Found: @xtuc/long@4.2.1
4270 verbose stack RangeError: Maximum call stack size exceeded
4270 verbose stack     at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:378:27)
4270 verbose stack     at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:396:9)
4270 verbose stack     at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:396:9)
4270 verbose stack     at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:396:9)```

禁用受控文件夹访问有帮助

禁用受控文件夹访问有帮助

使用 Windows 子系统 Linux 修复了此问题。顺便说一句,我的 Windows Defender 由我的组织策略控制。