我正在尝试建立一个构建环境来探索反应。我的构建过程使用gulp。
我安装了这样的软件包:
npm安装
在发现我需要安装一些与babel相关的内容并作出反应之后,我还运行了以下命令:
npm安装
我的.babelrc有这样的功能:
{“预设”:“@babel/预设反应”}
我的档案里有这样的东西:
gulp.task('scripts', function() {
return gulp.src(['./src/js/main.js' ])
.pipe(babel({
presets : ['@babel/preset/react']
}))
.pipe(concat('test.js'))
.pipe(gulp.dest('./js'))
.pipe(uglify())
.pipe(rename('test.min.js'))
.pipe(gulp.dest('./js')) ;
});当我运行“gulp脚本”时,我得到了这样的信息:
[22:51:14] Using gulpfile ~/play/learning-react-2/gulpfile.js
[22:51:14] Starting 'scripts'...
[22:51:14] 'scripts' errored after 59 ms
[22:51:14] Error in plugin "gulp-babel"
Message:
Cannot find module '@babel/core' (While processing preset: "/home/bob/play/learning-react-2/node_modules/@babel/preset-react/lib/index.js")我从node_modules中删除了babel-core,并使用以下命令重新安装了它:
npm安装--save @babel/core
如果我查看node_modules的内容,我会看到这些与babel相关的包:
babel-代码-框架/
babel-helper-builder-binary-assignment-operator-visitor/ babel-助手-呼叫-委托/
巴贝尔-帮手-定义-地图/
巴贝尔-帮手-爆炸-可分配-表达/
babel-助手-函数-名称/
巴贝尔-帮手-获得-功能-特性/
babel-帮手-升降机-变量/
巴贝尔-帮手-优化-呼叫-表达式/
babel-帮手-regex/
babel-助手-remap-异步生成器/
宝贝-帮手-替换-超级/
巴贝尔-信息/
babel-插件-检查-s 2015-常量/
babel-插件-语法-异步函数/
babel-plugin-语法-指数-运算符/
babel-plugin-语法-尾-函数-逗号/
babel插件-转换-异步到生成器/
babel-plugin-transform-es2015-arrow-functions/
babel-plugin-transform-es2015-block-scoped-functions/
babel-插件-转换-s 2015-区块范围/
babel-插件-转换-2015年-类/
babel-plugin-transform-es2015-computed-properties/
babel-插件-转换-2015年-破坏/
babel-插件-转换-s 2015-重复-键/
babel-plugin-transform-s 2015 for of/
babel-插件-转换-s 2015-函数-名称/
巴贝尔-插件-转换-2015年-文字/
babel-插件-转换-s 2015-模块-amd/
babel-plugin-transform-es2015-modules-commonjs/
babel-plugin-transform-es2015-modules-systemjs/
babel-插件-转换-s 2015-模块-umd/
巴贝尔-插件-转换-s 2015-对象-超级/
babel-插件-转换-2015年-参数/
babel-plugin-transform-es2015-shorthand-properties/
巴贝尔-插件-转换-2015年-传播/
babel-插件-转换-s 2015-粘滞-正则/
babel-plugin-transform-es2015-template-literals/
babel-插件-转换-s 2015-类型-符号/
babel-插件-转换-s 2015-unicode-regex/
babel-plugin-transform-exponentiation-operator/
babel-插件-转换-再生器/
babel-插件-转换-严格模式/
babel-预设-env/
babel-运行时/
babel-模板/
babel-导线/babel-类型/
我猜其中至少有一个是“巴贝尔核心”
所以..。我怎么才能让巴贝尔一饮而尽呢?我该怎么做呢?
发布于 2021-01-14 14:51:48
我也有过同样的问题。我通过删除node_modules和重新安装包(使用yarn或npm install)来解决这个问题。问题解决了。
发布于 2022-08-29 17:17:35
如果Victor's answer没有帮助,则通过运行npm cache clean/yarn cache clean或手动删除缓存文件夹来实现it may be worth a try to clean your machine's package cache。
https://stackoverflow.com/questions/59518390
复制相似问题