繁体   English   中英

尝试为 Meteor 应用程序提供服务时出现“babel-runtime”错误

[英]Error with 'babel-runtime' while trying to serve a Meteor app

我最近开始使用 Meteor 和 React。 我按照 Meteor 网站上的教程没有问题。

然后我尝试创建另一个项目,尝试遵循另一个教程(对于旧版本的 Meteor)。 沿着这条线的某个地方,Meteor 开始抛出一些模糊的错误。 在尝试重新开始后,我最终重新安装了 Meteor,它停止了抱怨。

但是,我又遇到了同样的问题。 具体来说,在创建一个全新的项目后:

meteor create myproject
cd myproject
meteor

服务器抛出以下错误:

[...]
W20161109-03:53:42.862(1)? (STDERR) Error: The babel-runtime npm package could not be found in your node_modules
W20161109-03:53:42.862(1)? (STDERR) directory. Please run the following command to install it:
W20161109-03:53:42.863(1)? (STDERR)
W20161109-03:53:42.863(1)? (STDERR)   meteor npm install --save babel-runtime
[...]

我按照我的吩咐去做,并尝试安装babel-runtime包。 服务器设法成功启动,但随后在运行时抛出以下错误:

Uncaught Error: Cannot find module 'babel-runtime/helpers/slicedToArray'
at Function.require.resolve

这一切仍在一个新创建的项目中工作,没有安装额外的包或更改代码。 我曾尝试在网上寻找解决方案,但虽然有很多关于已修复错误的参考,但我什么也没找到。 几个(问题)[ Babel - Error: Cannot find module 'babel-runtime/helpers/typeof' on StackOverflow 提出以下建议:

  1. 重新安装 NPM 模块 rm -rf node_modules 流星 npm install

  2. 更新 NPM 流星 npm update -g npm

我正在使用 Meteor 1.4.2、NPM 3.10.9、Ubuntu 16.04.1。

我遇到了同样的问题。 经过一番挖掘,发现了这个: https : //github.com/meteor/meteor/issues/8019

* Installing the `babel-runtime` npm package in your application
  `node_modules` directory is now required for most Babel-transformed code
  to work, as the Meteor `babel-runtime` package no longer attempts to
  provide custom implementations of Babel helper functions.
Consider trying it out by using the latest release candidate (not officially released yet):

meteor update --release 1.4.2.1-rc.1
And then:

meteor npm install --save babel-runtime

升级到 1.4.2.1-rc.1(然后在 11/9 今早升级到 1.4.2.1)后,错误得到解决。

尝试在项目目录中添加 package.json 文件,然后运行meteor

npm install --save babel-runtime

在命令行中。

您的项目名称中可能有空格 您所要做的就是创建另一个名称中没有空格的项目。 我知道从错误消息中检测原因非常困难,但事实就是如此。

我最近在使用meteor 1.11.1 时遇到了这个问题,这里的解决方案不起作用。 原来我的项目名称中有空格( Ghughu Server V2 ),我所要做的就是创建另一个没有空格的空格( GhughuServerV2 )。

PS即使您的项目路径中有空格,它也能正常工作,但项目名称中不能有空格。 此外,仅重命名目录不起作用。 您必须创建一个全新的项目或更改内部的一些配置(如果您在新创建的项目中工作,这似乎不切实际)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM