首页 文章

创建反应应用程序时,与babel的npm start(或yarn start)错误

提问于
浏览
1

我正在尝试这篇文章工作a react calculator我在 scripts 中使用 "start": "babel-node ./server/server.js" 设置了我的package.json . 当我运行 npm start 时,出现错误 . yarn start 在此处显示了更多详细信息错误消息 .

max @ DESKTOP-4J1U771 MINGW64~ / Documents / react-calculator(master)$ yarn start yarn run v1.7.0 warning package.json:无许可证字段$ babel-node ./server/server.js C:\ Users \ max \ Documents \ react-calculator \ node_modules \ babel-core \ lib \ transformation \ file \ logger.js:41 throw new Constructor(this._buildMessage(msg)); ^ ReferenceError:[BABEL] C:\ Users \ max \ Documents \ react-calculator \ server \ server.js:未知选项:base.0 . 有关选项的更多信息,请查看h ttp://babeljs.io/docs/usage/options/ . 此错误的常见原因是存在没有相应预设名称的配置选项对象 . 示例:无效:{presets:[{option:value}]}有效:{presets:[['presetName',{option:value}]]}有关预设配置的更多详细信息,请参阅https:// babeljs . io / docs / en / plugins#pluginpresets-op tions . 在LogManager.error(C:\ Users \ max \ Documents \ react-calculator \ node_modules \ babel-core \ lib \ transformation \ file \ logger.js:41:11)中的OptionManager.mergeOptions(C:\ Users \ max \在OptionManager.init上的Documents \ react-calculator \ node_modules \ babel-core \ lib \ transformation \ file \ options \ option-manager.js:226:20)(C:\ Users \ max \ Documents \ react-calculator \ node_modules \ babel-core \ lib \ transformation \ file \ op tions \ option-manager.js:368:12)在File.initOptions(C:\ Users \ max \ Documents \ react-calculator \ node_modules \ babel-core \ lib \ transformation) \ file \ inde x.js:212:65)在新文件(C:\ Users \ max \ Documents \ react-calculator \ node_modules \ babel-core \ lib \ transformation \ file \ index.js:135:24)at at Object.transformFileSync上的Pipeline.transform(C:\ Users \ max \ Documents \ react-calculator \ node_modules \ babel-core \ lib \ transformation \ pipelin e.js:46:16)(C:\ Users \ max \ Documents \ react-calculator \ node_modules \ babel-core \ lib \ api \ node.js:152:10)编译时(C:\ Users \ max \ Documents \ react-calculator \ node_modules \ babel-register \ lib \ nod) e.js:118:20)在Object.require.extensions的加载器(C:\ Users \ max \ Documents \ react-calculator \ node_modules \ babel-register \ lib \ node.js:144:14)中 . (匿名函数) )[as .js](C:\ Users \ max \ Documents \ react-calculator \ node_modules \ babel-register \ lib \ node.js:154:7)错误命令失败,退出代码为1. info访问https:// yarnpkg.com/en/docs/cli/run有关此>命令的文档 .

有谁看到这里发生了什么以及如何解决它?

1 回答

  • 0

    使用create-react-app . 它比配置babel和以旧方式创建React项目更简单 . 要使用它,请转到您希望项目所在的目录,然后键入您的终端:create-react-app [project-name] . 这将为您完成所有配置并使您更轻松 . 文章中提到的React的安装和配置已经过时,但您仍然可以按照该教程中的其他内容进行操作 . 祝好运!

相关问题