node.js - 为什么 nodemon 在使用 --exec babel-node 时失败?

标签 node.js babeljs nodemon

我已经安装了 bable-cli 和 babel-preset-env,在安装 nodemon 之后,当在 package.json 文件中使用以下内容时,npm start 无法加载我的应用程序:

"scripts": {
    "start": "nodemon src/index.js --exec babel-node"
  }

显示以下错误:

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

但使用以下内容时一切正常:

"scripts": {
    "start": "babel-node src/index.js"
  }

谢谢!

最佳答案

我遇到了同样的问题,然后这样解决了: “脚本”:{ “开始”:“babel-node src/index.js” “dev”:“nodemon --exec npm start”

关于node.js - 为什么 nodemon 在使用 --exec babel-node 时失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66726507/

相关文章:

reactjs - 在 Laravel 5.7 React 应用程序中,出现错误 : 'classProperties' isn't currently enabled

node.js - 找不到 nodemon 命令

sql-server - Node.js SQL 服务器在接收多个请求时崩溃

javascript - 运行后以编程方式停止nodemon

javascript - 如何向机器人添加其他功能?

c++ - 如何遍历对象中的属性

javascript - 防止重复插入文档

javascript - Node.js 产生颜色?

javascript - 使用 Babel,为什么函数的长度属性会根据异步与否而改变?

reactjs - 如何解决错误: "You gave us a visitor for the node type TSSatisfiesExpression but it' s not a valid type"?