Expo Init项目中出现“错误:spawn cmd ENOENT”

时间:2018-11-24 08:54:02

标签: node.js react-native npm expo enoent

我正在使用

启动一个新的React-Native项目
  

expo init firstexpo

但是我在命令提示符处遇到了这个错误

错误:生成cmd ENOENT

PS C:\Users\Alex\testing\firstexpo> expo start
[16:21:09] Starting project at C:\Users\Alex\testing\firstexpo
[16:21:11] Expo DevTools is running at http://localhost:19002
[16:21:11] Opening DevTools in the browser... (press shift-d to disable)
Error: spawn cmd ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:232:19)
    at onErrorNT (internal/child_process.js:407:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
PS C:\Users\Alex\testing\firstexpo>

npm启动错误找不到模块“ opn”

[16:38:49] Starting project at C:\Users\Alex\testing\firstexpo
[16:38:52] Expo DevTools is running at http://localhost:19002
[16:38:52] Opening DevTools in the browser... (press shift-d to disable)
[16:38:52] Cannot find module 'opn'
[16:38:52] Set EXPO_DEBUG=true in your env to view the stack trace.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! empty-project-template@ start: `expo start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the empty-project-template@ 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\Alex\AppData\Roaming\npm-cache\_logs\2018-11-24T08_38_52_344Z-debug.log

我对编码非常陌生,谁能告诉我如何解决该问题? 非常感谢。

Downgrade to v28

2 个答案:

答案 0 :(得分:0)

我使用此命令解决了我的错误。 “%SystemRoot%\ system32;”在PATH变量中。

答案 1 :(得分:0)

1-首先,您需要编辑系统环境变量并找到Windows Poweshell所在的位置,以便在“系统环境变量路径”中添加新内容

Add Window Powershell path in system environment variable path

2-然后以管理员身份打开Window PoweShell并编写以下两个命令:

:)升级Window PowerShell是因为您的nodejs和npm已更新,但是powershell尚未更新,因此它与您的npm start或expo start发生冲突,因此您需要升级Windows powershell

Upgrade Window PowerShell because your nodejs and npm is updated but powershell is not updated so its making conflict with your npm start or expo start,so you should need to upgrade windows powershell.

然后运行Cmd并同时运行您的项目npm start或expo start,它会很快起作用!

enter image description here

运气最佳!