笔记·约 1 分钟·更新于 2021.08.23

RN 踩坑记

某天,从git上拉取了最新代码后,运行 npm install 直接被生出一个错误: (node:23794) UnhandledPromiseRejectionWarning: Error: spawnSync /Users/yangjinlong/Shannon/WorkGitLab/GZJRHX/nodemodules/react-native/local-cli/setupenv.sh E…

某天,从git上拉取了最新代码后,运行 npm install 直接被生出一个错误: (node:23794) UnhandledPromiseRejectionWarning: Error: spawnSync /Users/yangjinlong/Shannon/WorkGitLab/GZ_JRHX/node_modules/react-native/local-cli/setup_env.sh EPERM


  • 先说结果

我使用的是 yarn add audit 命令解决了问题

  • 错误解决参考

设备问题

CODE
npm audit fix
// 或
yarn add audit fix

权限问题 让我重装了一晚上各种包的坑,最后发现跳错坑了,TMD 是文件权限的问题

(node:1437) UnhandledPromiseRejectionWarning: Error: spawnSync /Users/dengli/Desktop/new/Ddhv2/node_modules/react-native/local-cli/setup_env.sh EACCES

at Object.spawnSync (internal/child_process.js:1019:20)

at spawnSync (child_process.js:624:24)

at Object.execFileSync (child_process.js:652:15)

at Object.run (/Users/dengli/Desktop/new/Ddhv2/node_modules/react-native/local-cli/cliEntry.js:146:16)

(node:1437) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

(node:1437) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

最后救赎我的就一行命令

chmod -R 777 node_modules

要是还是运行不了,就重装一下

yarn add audit