Nodemon、babel-node未被识别为内部或外部命令、可操作程序或批处理文件

jk9hmnmh  于 2022-11-29  发布在  Node.js
关注(0)|答案(1)|浏览(228)

我一直在尝试使用npm start初始化localhost,但在终端中出现以下错误:

[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): backend\**\*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `babel-node backend/server.js`
'babel-node' is not recognized as an internal or external command,
operable program or batch file.
[nodemon] app crashed - waiting for file changes before starting...

根文件夹中的package.json为:

{
  "name": "abc",
  "version": "1.0.0",
  "description": "ABC",
  "main": "index.js",
  "scripts": {
    "start": "nodemon --watch backend --exec babel-node backend/server.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "cors": "^2.8.5",
    "express": "^4.17.3"
  },
  "devDependencies": {
    "@babel/cli": "^7.10.3",
    "@babel/core": "^7.10.3",
    "@babel/node": "^7.10.3",
    "@babel/preset-env": "^7.10.3",
    "nodemon": "^2.0.4"
  }
}

我在node_modules中也有这些文件。

  • 节点模块/.bin/babel-node
  • 节点模块/.bin/babel-node.cmd
  • 节点模块/@babel/节点/bin/babel-node.js

我刚开始在节点工作,不能想出如何解决这个问题。提前感谢。

pgccezyw

pgccezyw1#

试试这个
1.删除package-lock.json
1.删除文件夹node_modules及其所有内容
1.安装全局babel节点:npm安装-g @babel\节点
1.重新安装所有软件包:npm安装
1.重新启动应用程序:npm启动

相关问题