【问题标题】:Error while creating app using command prompt使用命令提示符创建应用程序时出错
【发布时间】:2021-09-22 14:13:17
【问题描述】:

我已经安装了 nodejs 并检查了 nodejs、npm 和 npx 版本。一切似乎都很好并且执行了npm install -g create-react-app,并且它也得到了正确执行。但是在写create-react-app myapp 之后,它在命令提示符上显示了这个错误。

Creating a new React app in `C:\Users\Dell\Documents\Javascript Tutorial && Summer training\reactjs course\todolist`

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

events.js:352
      throw er; // Unhandled 'error' event
      ^

Error: spawn C:\Windows\system32\cmd.exe ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess.cp.emit (C:\Users\Dell\AppData\Roaming\npm\node_modules\create-react-app\node_modules\cross-spawn\lib\enoent.js:34:29)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn C:\\Windows\\system32\\cmd.exe',
  path: 'C:\\Windows\\system32\\cmd.exe',
  spawnargs: [
    '/d',
    '/s',
    '/c',
    '"npm ^"install^" ^"--save^" ^"--save-exact^" ^"--loglevel^" ^"error^" ^"react^" ^"react-dom^" ^"react-scripts@0.9.x^""'
  ]
}

【问题讨论】:

    标签: javascript node.js reactjs npm npx


    【解决方案1】:

    这不是初始化 React 应用程序的正确方法,因为它不正确地使用了 npx

    尝试全局卸载create-react-app

    $ npm uninstall -g create-react-app
    

    然后初始化你的应用

    $ npx create-react-app myapp
    

    【讨论】:

    • 加$表示“'$'不是内部或外部命令、可运行程序或批处理文件。”,现在该怎么办
    • $ 只是表示它是一个shell命令,不要包含它
    猜你喜欢
    • 1970-01-01
    • 2015-05-14
    • 2011-03-24
    • 2017-06-19
    • 2014-11-06
    • 2021-06-01
    • 2014-08-16
    • 2018-02-22
    • 2020-07-24
    相关资源
    最近更新 更多