Skip to content

Commit

Permalink
changed require to dynamic imports
Browse files Browse the repository at this point in the history
In the previous state, the code presents the following error when the gulp command is ran: Error [ERR_REQUIRE_ESM]: require() of ES Module /.../node-test/node_modules/gulp-autoprefixer/index.js from /.../node-test/gulpfile.js not supported.
Instead change the require of index.js in /.../node-test/gulpfile.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/.../node-test/gulpfile.js:3:22) {
  code: 'ERR_REQUIRE_ESM'
}
  • Loading branch information
ShamarYarde authored Nov 24, 2023
1 parent 0c3934a commit 83e6f04
Showing 1 changed file with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ To use each plugin, you need to first install it via npm, then require any depen
2. Add the following dependency to `gulpfile.js`:

```js
const htmltidy = require("gulp-htmltidy");
import htmltidy from "gulp-htmltidy";
```

3. Add the following test to the bottom of `gulpfile.js`:
Expand Down Expand Up @@ -216,8 +216,8 @@ In the input version of the file, you may have noticed that we put an empty {{ht
2. Add the following dependencies to `gulpfile.js`:

```js
const autoprefixer = require("gulp-autoprefixer");
const csslint = require("gulp-csslint");
import autoprefixer from "gulp-autoprefixer";
import csslint from "gulp-csslint";
```

3. Add the following test to the bottom of `gulpfile.js`:
Expand Down Expand Up @@ -245,19 +245,13 @@ In the input version of the file, you may have noticed that we put an empty {{ht
]
```

5. Add this line after the const definitions:

```js
const { series } = require("gulp");
```

6. Export the css task using:
5. Export the css task using:

```js
exports.css = css;
```

7. Change the default task to:
6. Change the default task to:

```js
exports.default = series(html, css);
Expand All @@ -278,8 +272,8 @@ Here we grab our `style.css` file, run csslint on it (which outputs a list of an
2. Add the following dependencies to `gulpfile.js`:

```js
const babel = require("gulp-babel");
const jshint = require("gulp-jshint");
import babel from "gulp-babel";
import jshint from "gulp-jshint"
```

3. Add the following test to the bottom of `gulpfile.js`:
Expand Down

0 comments on commit 83e6f04

Please sign in to comment.