You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React项目调试遇Error 303与604问题求助

VS Code调试React项目报错+npm命令不识别求助

背景

我是前端新手,正在做一个叫「jammming」的作品集项目,用Create React App搭建的,现在碰到两个问题卡壳了:VS Code调试报错,以及终端没法识别npm命令。

问题1:调试报错+调试选项丢失

在VS Code里启动调试时,弹出错误提示:

An error occurred while launching the application. Seems to be that you are trying to debug from within directory that is not a React Native project root. If so, please, follow these instructions: https://github.com/microsoft/vscode-react-native#customization (error code 604) (error code 303)

我试着把.vscode/launch.json移到app文件夹里,但VS Code直接找不到这个调试选项了。

原launch.json配置

{ 
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Windows",
            "cwd": "${workspaceFolder}",
            "type": "reactnative",
            "request": "launch",
            "platform": "windows"
        }
    ]
}

问题2:npm命令不识别

终端输入npm命令时系统提示不认识这个命令,点击package.json里scripts上方的调试按钮也会触发同样的错误。

项目配置文件

manifest.json

{
  "short_name": "React App",
  "name": "Create React App Sample",
  "icons": [
    {
      "src": "favicon.ico",
      "sizes": "192x192",
      "type": "image/png"
    }
  ],
  "start_url": "./index.html",
  "display": "standalone",
  "theme_color": "#000000",
  "background_color": "#ffffff"
}

package.json

{
  "name": "jammming",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  },
  "devDependencies": {
    "react-scripts": "5.0.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}

文件布局

项目根目录下有app、public、src三个文件夹,package.json在根目录;原来的launch.json放在.vscode文件夹里,后来我移到了app文件夹中。

内容的提问来源于stack exchange,提问作者Kawaii concept

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.20 23:00:57