Babel Transpiler 无法使用 Nodemon 运行
Babel Transpiler failing to run with Nodemon
问题:
无法将 Babel Transpiler 与 Nodemon 一起使用
详情:
在 package.json 我有:
"scripts": {
"start": "nodemon --exec babel-node --presets=es2015 -- src/app.js"
},
"dependencies": {
"nodemon": "^1.18.4"
},
"devDependencies": {
"@babel/cli": "^7.1.2",
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0"
}
当我 运行 npm start
我的理解是 nodemon 应该启动保存和 运行 babel 转译器;但是,我在终端中得到以下信息。
Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel.
我认为这是由 6.26 的 babel-cli
依赖性引起的,但是当我删除它时它发出尖叫声:
[nodemon] failed to start process, "babel-node" exec not found
通过搜索好的 ol' google 机器,我看到其他人的设置更复杂,他们的解决方案似乎飞过我的头顶。
娱乐步骤:
运行 npm init -y
& npm i nodemon
按照此处的说明进行操作:https://babeljs.io/setup#installation (nodemon) 已选择
运行 npm install @babel/core --save-dev
因为我被警告没有安装核心。
运行 npm start
当 运行使用 nodemon 连接 Babel 时,您需要包含这些包。
"devDependencies": {
"@babel/cli": "^7.1.2",
"@babel/core": "^7.1.2",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"@babel/node": "^7.0.0",
"nodemon": "^1.18.4"
}
然后将您的 npm 运行 脚本调整为:
"start": "nodemon app/index.js --exec babel-node app/index.js"
感谢 Babel Slack 频道的回答!
问题:
无法将 Babel Transpiler 与 Nodemon 一起使用
详情:
在 package.json 我有:
"scripts": {
"start": "nodemon --exec babel-node --presets=es2015 -- src/app.js"
},
"dependencies": {
"nodemon": "^1.18.4"
},
"devDependencies": {
"@babel/cli": "^7.1.2",
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0"
}
当我 运行 npm start
我的理解是 nodemon 应该启动保存和 运行 babel 转译器;但是,我在终端中得到以下信息。
Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel.
我认为这是由 6.26 的 babel-cli
依赖性引起的,但是当我删除它时它发出尖叫声:
[nodemon] failed to start process, "babel-node" exec not found
通过搜索好的 ol' google 机器,我看到其他人的设置更复杂,他们的解决方案似乎飞过我的头顶。
娱乐步骤:
运行
npm init -y
&npm i nodemon
按照此处的说明进行操作:https://babeljs.io/setup#installation (nodemon) 已选择
运行
npm install @babel/core --save-dev
因为我被警告没有安装核心。运行
npm start
当 运行使用 nodemon 连接 Babel 时,您需要包含这些包。
"devDependencies": {
"@babel/cli": "^7.1.2",
"@babel/core": "^7.1.2",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"@babel/node": "^7.0.0",
"nodemon": "^1.18.4"
}
然后将您的 npm 运行 脚本调整为:
"start": "nodemon app/index.js --exec babel-node app/index.js"
感谢 Babel Slack 频道的回答!