【发布时间】:2023-01-18 02:21:47
【问题描述】:
我跑:
npx create-react-app my-app
并得到以下响应。
Creating a new React app in /home/austin/executable-bash/test_dir/my-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
added 1379 packages in 35s
186 packages are looking for funding
run `npm fund` for details
Initialized a git repository.
Installing template dependencies using npm...
npm WARN deprecated source-map-resolve@0.6.0: See https://github.com/lydell/source-map-resolve#deprecated
added 39 packages in 4s
186 packages are looking for funding
run `npm fund` for details
Removing template package using npm...
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /home/austin/executable-bash/test_dir/my-app/node_modules/cra-template
npm ERR! dest /home/austin/executable-bash/test_dir/my-app/node_modules/.cra-template-AJu7jvgH
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/home/austin/executable-bash/test_dir/my-app/node_modules/cra-template' -> '/home/austin/executable-bash/test_dir/my-app/node_modules/.cra-template-AJu7jvgH'
npm ERR! [Error: EACCES: permission denied, rename '/home/austin/executable-bash/test_dir/my-app/node_modules/cra-template' -> '/home/austin/executable-bash/test_dir/my-app/node_modules/.cra-template-AJu7jvgH'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/home/austin/executable-bash/test_dir/my-app/node_modules/cra-template',
npm ERR! dest: '/home/austin/executable-bash/test_dir/my-app/node_modules/.cra-template-AJu7jvgH'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/austin/.npm/_logs/2022-06-02T18_59_15_191Z-debug-0.log
`npm install --no-audit --save @testing-library/jest-dom@^5.14.1 @testing-library/react@^13.0.0 @testing-library/user-event@^13.2.1 web-vitals@^2.1.0` failed
权限问题似乎与 node_modules 有关里面它刚刚创建的应用程序。很奇怪吧? 我有一个简单的解决方法来更改项目内部的权限:
cd my-app
更改权限:
chown -R $USER node_modules
并安装软件包:
npm i
这行得通,但出于显而易见的原因,最好有npx create-react-app实际上像它应该的那样工作。有任何想法吗?
【问题讨论】:
标签: windows ubuntu node-modules create-react-app npx