将 React 添加到工作区失败,EACCES:权限被拒绝,mkdir '/home/mint/.cache/Cypress'

Posted

技术标签:

【中文标题】将 React 添加到工作区失败,EACCES:权限被拒绝,mkdir \'/home/mint/.cache/Cypress\'【英文标题】:Adding React to a workspace failed, EACCES: permission denied, mkdir '/home/mint/.cache/Cypress'将 React 添加到工作区失败,EACCES:权限被拒绝,mkdir '/home/mint/.cache/Cypress' 【发布时间】:2019-11-02 08:02:04 【问题描述】:

我正在尝试在空的 nx 工作区上添加 @nrwl/react

所以我正在创建一个空的 nx 工作区:yarn create nx-workspace <app_name>

然后当我使用yarn ng add @nrwl/react 添加 React 时,我遇到了这个错误(即使使用 sudo):

> cypress@3.3.1 postinstall /home/mint/dev/Learn/Nx/my-app/node_modules/cypress
> node index.js --exec install

Cypress cannot write to the cache directory due to file permissions

See discussion and possible solutions at
https://github.com/cypress-io/cypress/issues/1281

----------

Failed to access /home/mint/.cache/Cypress:

EACCES: permission denied, mkdir '/home/mint/.cache/Cypress'

----------

Platform: linux (Linux Mint - )
Cypress Version: 3.3.1
npm WARN @ngtools/webpack@8.0.1 requires a peer of @angular/compiler-cli@>=8.0.0-beta.0 < 9.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted "os":"darwin","arch":"any" (current: "os":"linux","arch":"x64")

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cypress@3.3.1 postinstall: `node index.js --exec install`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the cypress@3.3.1 postinstall 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!     /home/mint/.npm/_logs/2019-06-18T21_51_47_231Z-debug.log
Package install failed, see above.
Workspace creation failed, see above.

在我的本地机器上手动安装 Cypress 并不能解决问题。

【问题讨论】:

【参考方案1】:

尝试使用以下方式创建您的应用:

sudo yarn create nx-workspace <app_name>

【讨论】:

我无法重现该问题,也不记得我是如何解决的(应该已经写了一个答案)。但是将 sudo 与 Yarn 或 Npm 一起使用总是一个坏主意。

以上是关于将 React 添加到工作区失败,EACCES:权限被拒绝,mkdir '/home/mint/.cache/Cypress'的主要内容,如果未能解决你的问题,请参考以下文章

将 react-native 添加到 monorepo 后,React apollo hooks 失败

node-sass安装失败的问题 stack Error: EACCES: permission denied, mkdir

打开失败:EACCES(权限被拒绝)ANDROID 11

打开失败:Android 中的 EACCES(权限被拒绝)

java.io.filenotfoundexception 在设备上打开失败的 eacces(权限被拒绝)

Android 11 打开失败:EACCES(权限被拒绝)