有没有办法让npx在我的电脑上创建一个React应用程序



我对React和Node.js完全陌生,尽管我用各种语言编写了软件,并使用Cold Fusion创建了web应用程序。我使用的是64位Windows 10家庭版。我购买了Robin Wieruch的书,并按照说明下载了Node.js、React和Visual Studio代码。当我输入npx创建反应应用程序黑客时,我收到了错误,并尝试了youtube视频中的各种修复。没有成功。代码如下。有没有解决办法?

C:UsersWarrenDocumentsproj>npm uninstall -g create-react-app && npm i -g npm@latest && npm cache clean -f
removed 66 packages in 1.335s
C:UserswarreAppDataRoamingnpmnpm -> C:UserswarreAppDataRoamingnpmnode_modulesnpmbinnpm-cli.js
C:UserswarreAppDataRoamingnpmnpx -> C:UserswarreAppDataRoamingnpmnode_modulesnpmbinnpx-cli.js
+ npm@7.19.1
added 256 packages from 146 contributors in 13.76s
npm WARN using --force Recommended protections disabled.
C:UsersWarrenDocumentsproj>npx create-react-app hacker
Need to install the following packages:
create-react-app
Ok to proceed? (y) y
(node:11992) UnhandledPromiseRejectionWarning: Error: EPERM: operation not permitted, mkdir 'C:UsersWarrenDocumentsprojhacker'
at Object.mkdirSync (fs.js:1009:3)
at Object.module.exports.makeDirSync (C:UserswarreAppDataLocalnpm-cache_npxc67e74de0542c87cnode_modulesfs-extralibmkdirsmake-dir.js:101:15)
at createApp (C:UserswarreAppDataLocalnpm-cache_npxc67e74de0542c87cnode_modulescreate-react-appcreateReactApp.js:255:6)
at C:UserswarreAppDataLocalnpm-cache_npxc67e74de0542c87cnode_modulescreate-react-appcreateReactApp.js:226:9
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:11992) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:11992) [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.

在GitHub上,有人解决了与您相同的问题,

EPERM:不允许操作,mkdir。。。

通过运行

npm install -g create-react-app
npx create-react-app

–即首先在全局范围内安装create-react-app

修复几乎微不足道。我查看了项目文件夹的属性,我想在其中创建新的React应用程序。我修改了用户和系统的写入权限以启用写入。npx create-rect应用程序我的应用程序运行顺利。谢谢大家。我希望这能帮助其他人。我应该意识到,当MkDir操作失败时,这是一个读/写问题。

是的,您可以

首先创建新文件夹(应用程序名称(

```Mkdir appName```

将Cd放入您的新应用程序Cd appName第三次运行npx命令npx create-react-app ./

它将工作

相关内容

最新更新