Metro boundler不起作用-Expo / React Native

问题描述

我想通过这些命令运行React Native应用程序:

npm i -g expo-cli
expo init myapp
cd myapp
npm start

但是出现以下错误,地铁限制器无法正常工作:

opening DevTools in the browser... (press shift-d to disable)
Error: spawn powershell ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processticksAndRejections (internal/process/task_queues.js:84:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ start: `expo start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ start 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!     C:\Users\nathan-hp\AppData\Roaming\npm-cache\_logs\2020-09-22T14_48_10_269Z-debug.log

我将此添加到了路径:

C:\Windows\System32

但是我仍然收到上面的错误

解决方法

好的,这就是解决方案: 问题是:

Error: spawn powershell ENOENT
  1. 所以我需要添加:

    C:\ Windows \ System32 \ WindowsPowerShell \ v1.0

到路径。

  1. 我以管理员身份打开Windows PowerShell 并运行:

    Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force

  2. 在cmd中再次运行npm start,然后打开Metro boundler