运行 yarn start on Windows 10 一直失败
Running yarn start on Windows 10 keeps failing
我正在将 Web 项目从我的 Mac 移动到 Windows 10 PC。我使用 Github Desktop 下载所有文件,并使用 Visual Studio Code 处理我的项目。每次我 运行 同时 npm start
或 yarn start
我都会收到此错误。我尝试使用其他脚本终端删除 yarn.lock
、package-lock.json
、node_modules
,清除我的缓存,npm install
npm rebuild
,yarn install
。我能找到的所有东西都不起作用,我不知道该怎么做。任何帮助,将不胜感激。谢谢!
错误信息如下:
Starting the development server...
events.js:200
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:81:21) {
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn cmd',
path: 'cmd',
spawnargs: [ '/s', '/c', 'start', '""', '/b', '"http://localhost:3000/"' ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
好的,仔细看这个:
{
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn cmd',
path: 'cmd',
spawnargs: [ '/s', '/c', 'start', '""', '/b', '"http://localhost:3000/"' ]
}
errno: 'ENOENT'
表示找不到文件或目录
path: 'cmd'
表示在通过 Node.js 生成过程 cmd
时在本地或全局找不到可执行文件 cmd
- 现在,我不想详述。只要知道您的操作系统需要跟踪一些可以全局访问的变量即可。其中一个变量称为
$PATH
。 $PATH
中提到的目录中的可执行文件可以从系统的任何位置访问。
- 这里,
'C:\Windows\system32'
是 windows 保存一些关键可执行文件的路径。 cmd.exe
就是其中之一。路径已从 $PATH 变量中以某种方式删除。为了解决这个问题,一个简单的解决方案是:
- 转到
start-menu
-> search
并输入 environment variables
并打开它
- 将有一个名为 PATH 的变量。向其附加
C:\Windows\system32
并按确定。如果您使用 Windows 7 或更低版本,请在 ;
之前添加一个分号
- 重新启动您的终端或 IDE 或代码编辑器并尝试 运行 该应用程序。看看是不是又报错了
我正在将 Web 项目从我的 Mac 移动到 Windows 10 PC。我使用 Github Desktop 下载所有文件,并使用 Visual Studio Code 处理我的项目。每次我 运行 同时 npm start
或 yarn start
我都会收到此错误。我尝试使用其他脚本终端删除 yarn.lock
、package-lock.json
、node_modules
,清除我的缓存,npm install
npm rebuild
,yarn install
。我能找到的所有东西都不起作用,我不知道该怎么做。任何帮助,将不胜感激。谢谢!
错误信息如下:
Starting the development server...
events.js:200
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:81:21) {
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn cmd',
path: 'cmd',
spawnargs: [ '/s', '/c', 'start', '""', '/b', '"http://localhost:3000/"' ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
好的,仔细看这个:
{
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn cmd',
path: 'cmd',
spawnargs: [ '/s', '/c', 'start', '""', '/b', '"http://localhost:3000/"' ]
}
errno: 'ENOENT'
表示找不到文件或目录path: 'cmd'
表示在通过 Node.js 生成过程 - 现在,我不想详述。只要知道您的操作系统需要跟踪一些可以全局访问的变量即可。其中一个变量称为
$PATH
。$PATH
中提到的目录中的可执行文件可以从系统的任何位置访问。 - 这里,
'C:\Windows\system32'
是 windows 保存一些关键可执行文件的路径。cmd.exe
就是其中之一。路径已从 $PATH 变量中以某种方式删除。为了解决这个问题,一个简单的解决方案是:- 转到
start-menu
->search
并输入environment variables
并打开它 - 将有一个名为 PATH 的变量。向其附加
C:\Windows\system32
并按确定。如果您使用 Windows 7 或更低版本,请在;
之前添加一个分号 - 重新启动您的终端或 IDE 或代码编辑器并尝试 运行 该应用程序。看看是不是又报错了
- 转到
cmd
时在本地或全局找不到可执行文件 cmd