title: ReferenceError: require is not defined in ES module scope, you can use import instead gulp sass
body: <p>I got an error when using this line of code</p>
  <pre><code>const sass = require('gulp-sass')(require('sass'));
  </code></pre>
  <p>The error output is  :</p>
  <pre><code>Requiring external module babel-register
  ReferenceError: require is not defined in ES module scope, you can use import instead
  This file is being treated as an ES module because it has a '.js' file extension and 'C:\xampp-clean\htdocs\myfirsttheme\package.json' contains &quot;type&quot;: &quot;module&quot;. T
  o treat it as a CommonJS script, rename it to use the '.cjs' file extension.
  </code></pre>
  <p>I have changed</p>
  <pre><code>const sass = require('gulp-sass')(require('sass'));
  </code></pre>
  <p>the error disappeared but I am getting this error :</p>
  <pre><code>Requiring external module babel-register
  TypeError: Cannot read property 'prod' of undefined
  </code></pre>
  <p>and this line is causing the error :</p>
  <pre><code>const PRODUCTION = yargs.argv.prod;
  </code></pre>
  <p>Do anyone has an idea?</p>
  <p>I have tried a lot and googled this error but I did not find a solution , do anyone has an idea about this ?
  Thanks in advance</p>