Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/432.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript babel Transpile代码使用绝对导入_Javascript_Babeljs - Fatal编程技术网

Javascript babel Transpile代码使用绝对导入

Javascript babel Transpile代码使用绝对导入,javascript,babeljs,Javascript,Babeljs,使用@babel/cli和以下命令传输代码: babel --plugins @babel/plugin-transform-arrow-functions www/js/origin.js --out-file www/js/result.js 生成需要使用绝对路径从我的计算机导入的文件。当然,在服务器上运行它会因为找不到路径而中断 以下是绝对进口的一个例子: import _slicedToArray from "/Users/myself/project/node_modules/@ba

使用
@babel/cli
和以下命令传输代码:

babel --plugins @babel/plugin-transform-arrow-functions www/js/origin.js --out-file www/js/result.js
生成需要使用绝对路径从我的计算机导入的文件。当然,在服务器上运行它会因为找不到路径而中断

以下是绝对进口的一个例子:

import _slicedToArray from "/Users/myself/project/node_modules/@babel/runtime/helpers/builtin/es6/slicedToArray";
import _createClass from "/Users/myself/project/node_modules/@babel/runtime/helpers/builtin/es6/createClass";
import _inherits from "/Users/myself/project/node_modules/@babel/runtime/helpers/builtin/es6/inherits";
import _possibleConstructorReturn from "/Users/myself/project/node_modules/@babel/runtime/helpers/builtin/es6/possibleConstructorReturn";
import _getPrototypeOf from "/Users/myself/project/node_modules/@babel/runtime/helpers/builtin/es6/getPrototypeOf";
import _classCallCheck from "/Users/myself/project/node_modules/@babel/runtime/helpers/builtin/es6/classCallCheck";
import _typeof from "/Users/myself/project/node_modules/@babel/runtime/helpers/builtin/es6/typeof";
传输文件是否有任何方法可以包含它需要的所有内联内容

目前我没有使用任何特定的
babel.config.js
babelrc
文件。

如中所述,react应用程序预设有一个名为
absoluteRuntime
的选项,默认设置为
true
。因此,请尝试将其设置为
false
,如下所示

 "presets": [
["react-app", { "absoluteRuntime": false }],]

最初的答案是在那一问题上的。我只是为了其他人的利益在这里复制。

你一定在某个地方有一个babelrc,无论它是
.babelrc
文件、
.babelrc.js
文件还是
包.json#babel
字段,因为这些导入是你必须通过
@babel/plugin transform runtime
模块选择的。它可能在某个父文件夹中。使用--lrc不会产生相同的结果。我们试图删除使用@vue/app预设的babel.config.js,但没有改变。嗯,我不确定。你能做一个可复制的例子吗?肯定有其他插件从某处加载。我遇到了同样的问题。你想出解决办法了吗?没有,没有找到办法