serii81
@serii81
Я люблю phр...

Как решить «'core-js/modules/web.dom-collections.for-each»?

Добрый день.
Создал папку со сборщиком gulp в папке, где находятся все мои проекты.
Когда нужно поработать над каким-то проектом, просто в терминале перемещаюсь в папку со сборщиком и запускаю gulp.

Содержимое package.json
{
  "name": "window",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "browserslist": [
    "> 1%",
    "not dead"
  ],
  "devDependencies": {
    "@babel/core": "^7.7.4",
    "@babel/preset-env": "^7.7.4",
    "babel": "^6.23.0",
    "babel-core": "^6.26.3",
    "babel-loader": "^8.0.6",
    "browser-sync": "^2.26.12",
    "core-js": "^3.4.2",
    "gulp": "^4.0.2",
    "gulp-autoprefixer": "^7.0.1",
    "gulp-notify": "^3.2.0",
    "gulp-sass": "^4.1.0",
    "gulp-sourcemaps": "^2.6.5",
    "gulp-wait": "0.0.2",
    "webpack": "^4.41.2",
    "webpack-stream": "^5.2.1"
  }
}


Содержимое gulp.

"use strict";

const gulp = require("gulp");
const webpack = require("webpack-stream");
const sass = require('gulp-sass');
const autoprefixer = require("gulp-autoprefixer");
const sourcemaps = require('gulp-sourcemaps');
const wait = require('gulp-wait'), notify = require("gulp-notify");
const browserSync = require("browser-sync");

// let siteUrl = 'http://wc-estore.host1670806.hostland.pro/';
// let siteDir = '../wc-estore/';

// let siteUrl = 'http://gadda.cf/';
// let siteDir = '../bs-gadda/';

// let siteUrl = 'http://gadda.cf/';
// let siteDir = '../vue/';

// let siteDir = '../gsap/';
// let siteDir = '../javascript-petricenco/';

// let siteUrl = 'http://javascript-petricenco.host1670806.hostland.pro/';
// let siteDir = '../javascript-petricenco/';

let siteUrl = 'http://zuccato.cf/';
let siteDir = '../bs-zuccato/';

// const siteDir = '../bs-bunavestire/';
// const siteUrl = 'http://wp-bunavestire.host1670806.hostland.pro/';

//let siteDir = '../js-movies/';

// let siteUrl = 'http://dev.ilcaffecheaspettavi.it/';
// let siteDir = '../bs-alytaly/';

// let siteUrl = 'http://bassoservizi.cf/';
// let siteDir = '../bs-bassoservizi/';

//let siteUrl = 'http://consorziostorm.cf/';
//let siteDir = '../bs-consorzio/';

// let siteUrl = 'https://myrewind.it/';
// let siteDir = '../bs-rewind/';

// let siteUrl = 'http://bertan.ml/';
// let siteDir = '../bs-bertan/';

//let siteUrl = 'http://proseccoborgoluce.cf//';
//let siteDir = '../bs-proseccobordoluce/';

let isDev = true;
let webpackConfig = {
	output: {
		filename: "webpack.js"
	},
	watch: false,
	module: {
		rules: [
			{
				test: /\.m?js$/,
				exclude: /(node_modules|bower_components)/,
				use: {
					loader: 'babel-loader',
					options: {
						presets: [['@babel/preset-env', {
							debug: true,
							corejs: 3,
							useBuiltIns: "usage"
						}]]
					}
				}
			}
		]
	},
	mode: isDev ? 'development' : 'production',
	devtool: isDev ? 'eval-source-map' : 'none',
};

gulp.task('webpack', function () {
	return gulp.src(siteDir + 'assets/js/main.js')
		.pipe(webpack(webpackConfig))
		.pipe(gulp.dest(siteDir + 'assets/js/'))
		.pipe(browserSync.reload({
			stream: true
		}));
});

gulp.task("scss", function () {
	return gulp.src(siteDir + 'assets/scss/my.scss')
		// .pipe(plumber())
		.pipe(sourcemaps.init())
		.pipe(wait(500))
		.pipe(sass({
			outputStyle: 'expanded',
			allowEmpty: true
		}).on('error', notify.onError(function (error) {
			return 'An error occurred while compiling sass.\nLook in the console for details.\n' + error;
		})))
		.pipe(autoprefixer({
			cascade: false
		}))
		.pipe(sourcemaps.write('.'))
		.pipe(gulp.dest(siteDir + 'assets/css/'))
		.pipe(browserSync.reload({stream: true}));
});

gulp.task("watch", function () {
	gulp.watch(siteDir + 'assets/scss/**/*.scss', gulp.series('scss'));
	gulp.watch(siteDir + 'assets/js/modules/**/*.js', gulp.series('webpack'));
});

gulp.task('browser-sync', function () {
	browserSync.init({
		proxy: {
			target: siteUrl,
			ws: true
		},
		reloadDelay: 1000
	});

	// browserSync.init({
	// 	server: {
	// 		baseDir: siteDir
	// 	},
	// 	notify: true
	// });
	gulp.watch(siteDir + "**/*.html").on('change', browserSync.reload);
	gulp.watch(siteDir + "**/*.php").on('change', browserSync.reload);
	gulp.watch(siteDir + "**/*.css").on('change', browserSync.reload);
	gulp.watch(siteDir + "**/*.js").on('change', browserSync.reload);
});

// gulp.task('default', gulp.series('browser-sync'));
// gulp.task('default', gulp.parallel('scss', 'watch', 'browser-sync'));
// gulp.task('default', gulp.parallel('watch', 'browser-sync'));
gulp.task('default', gulp.series('webpack', 'scss', gulp.parallel('watch', 'browser-sync')));


Содержимое main.js

import homeIntroAnimation from "./modules/gsap/home-intro";
import prodottiPage from "./modules/gsap/prodotti--page";
import pageIntro from "./modules/gsap/page-intro";
import featuresItems from "./modules/gsap/features-items";
import termicoPostImg from "./modules/gsap/termico-post-img";
import produzionePost from "./modules/gsap/produzzione-post";
import servicesBlock from "./modules/gsap/services-block";
import benefits from "./modules/gsap/benefits";
import referenze from "./modules/gsap/referenze";
import address from "./modules/gsap/address";
import documentItemHover from "./modules/document-item";
import counterUp from "./modules/counter-up";

document.addEventListener('DOMContentLoaded', function () {
	homeIntroAnimation();
	prodottiPage();
	pageIntro();
	featuresItems();
	termicoPostImg();
	produzionePost();
	servicesBlock();
	benefits();
	referenze();
	address();
	documentItemHover();
	counterUp();
});


Когда запускаю task gulp wepack, то получаю ошибку

@ ../bs-zuccato/assets/js/modules/document-item.js 1:0-54
 @ ../bs-zuccato/assets/js/main.js
../bs-zuccato/assets/js/modules/counter-up.js
Module not found: Error: Can't resolve 'core-js/modules/web.dom-collections.for-each' in '/home/serii/Sites/bs-zuccato/assets/js/modules'
resolve 'core-js/modules/web.dom-collections.for-each' in '/home/serii/Sites/bs-zuccato/assets/js/modules'
  Parsed request is a module
  No description file found
  resolve as module

В чем может быть проблема?
  • Вопрос задан
  • 191 просмотр
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы