首页 > 解决方案 > 启动 Meteor 应用程序时出错 + react (static-html)

问题描述

我有一个使用 Meteor 框架 + React 运行的应用程序。我正在尝试使用npm start命令启动应用程序,但我不断收到有关静态 html 文件的这些错误。我对流星很陌生,所以我尝试在下面运行这些命令:

meteor remove static-html
meteor add blaze-html-templates

但我仍然遇到同样的错误......

=> Errors prevented startup:                  

   While processing files with static-html (for target web.browser):
   deploy/bundle/programs/web.browser/body.html:1: Expected one of: <body>, <head>, <template>
   deploy/bundle/programs/web.browser/head.html:1: Expected one of: <body>, <head>, <template>
   deploy/bundle/programs/web.browser.legacy/body.html:1: Expected one of: <body>, <head>, <template>
   deploy/bundle/programs/web.browser.legacy/head.html:1: Expected one of: <body>, <head>, <template>

   While processing files with static-html (for target web.browser.legacy):
   deploy/bundle/programs/web.browser/body.html:1: Expected one of: <body>, <head>, <template>
   deploy/bundle/programs/web.browser/head.html:1: Expected one of: <body>, <head>, <template>
   deploy/bundle/programs/web.browser.legacy/body.html:1: Expected one of: <body>, <head>, <template>
   deploy/bundle/programs/web.browser.legacy/head.html:1: Expected one of: <body>, <head>, <template>

=> Your application has errors. Waiting for file change.

我很感激任何帮助

标签: javascripthtmlreactjsnpmmeteor

解决方案


您需要reactreact-dom渲染反应组件

meteor npm install --save react react-dom

您需要删除blaze添加添加static-html回来。static-html用于渲染 init html 元素,然后react可以从那里接管。

meteor remove blaze-html-templates
meteor add static-html

React 流星指南 https://guide.meteor.com/react.html


推荐阅读