DEV Community

Discussion on: Deploy to Github Pages like a pro with Github Actions

Collapse
 
beatrizsmerino profile image
Beatriz Sopeña Merino • Edited

Hi!!!, Great post I have been using the gh-pages-deploy.js script for a while and it worked perfectly, but for some reason now I get an error when usingrequire`.

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module...
...require() of ES modules is not supported...is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.

Is this happening to anyone?

https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l7mysc2axiuhoo71h1re.png

Collapse
 
the_one profile image
Roland Doda

Hi, thanks.
Probably it's an error coming from upgrading packages. For instance, chalk and other libraries that gh-pages-deploy script uses, are now ESM only!
If you want me to help you, please drop me a message on Linkedin with a screenshot of the error you are getting.

Collapse
 
beatrizsmerino profile image
Beatriz Sopeña Merino

Thanks Ronald!
Right, I was trying a lot of things for a while and finally found it by installing an older version of the packages.

    "dependencies": {
        "chalk": "^4.1.2",
        "execa": "^5.1.1",
        "node-emoji": "^1.11.0",
    },
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
the_one profile image
Roland Doda

Glad to see that you fixed it.

Thread Thread
 
beatrizsmerino profile image
Beatriz Sopeña Merino

I was also getting some errors in the yml file.
https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wdxdsqk54ds9w8myekjd.png

I solved it by updating it following the structure of this file :
github.com/Rolanddoda/vue-cli-plug...
https://dev-to-uploads.s3.amazonaws.com/uploads/articles/onysv4ohfp8kxs8j9v62.png

... and the name of my npm script also had a different name

I leave it here written down in case someone else finds it helpful.

Thread Thread
 
the_one profile image
Roland Doda

Thanks for that. Yes setup-node@v1.1.0 is deprecated and setup-node@v2 should be used. I will make sure to update the article. Since you are using vue and you found the vue-cli plugin, then I guess you don't have to follow this article anymore. You can just install the plugin and everything that is in that article will automatically be done for you.

Thread Thread
 
beatrizsmerino profile image
Beatriz Sopeña Merino

Thanks, yes I will take a look at the repo, when I have time, it is more updated and I see that there are more automations to get the user's name and email.

Thread Thread
 
the_one profile image
Roland Doda

Yup. :)