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

移动index.js后执行npm run dev提示nodemon未识别的问题求助

解决步骤

1. 修复nodemon未识别问题

报错nodemon is not recognized as internal or external command的核心原因是本地项目未安装nodemon依赖,npm脚本优先读取本地node_modules/.bin下的命令,而非全局环境。执行以下命令安装本地开发依赖:

npm install nodemon --save-dev

2. 修正脚本中的文件路径

package.json位于项目根目录,npm脚本的工作目录默认是根目录,因此文件路径需相对于根目录编写,而非相对脚本执行位置:
修改后的scripts配置如下:

"scripts": {
  "start": "nodemon server/index/index.js",
  "dev": "set NODE_ENV=development && nodemon server/index/index.js",
  "prod": "set NODE_ENV=production && nodemon server/index/index.js"
}

注:你之前尝试的../index/index.js是错误路径——根目录没有上级目录,因此无法定位到目标文件。

3. 验证修复

执行命令测试是否正常启动:

npm run dev

内容的提问来源于stack exchange,提问作者Daniel Corona

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.21 16:40:15