flexdinesh / blogster

A collection of beautiful, accessible and performant Astro blog templates.
https://blogster-sleek.netlify.app
MIT License
609 stars 73 forks source link

require is not defined #7

Open hut36 opened 1 year ago

hut36 commented 1 year ago

How to reproduce:

  1. run npx create-blogster@latest --theme sleek
  2. run cd my-blogster-blog
  3. run yarn run dev --host
  4. visit http://127.0.0.1:3000/blog/basic-markdown-style-guide

The page displays an error message:

require is not defined

/my-blogster-blog/.yarn/cache/prismjs-npm-1.29.0-6faa5b04b8-007a8869d4.zip/node_modules/prismjs/components/index.js:1:33

> 1 | const components = require('../components.js');
    |                                 ^
  2 | const getLoader = require('../dependencies');

ReferenceError: require is not defined
    at /.yarn/cache/prismjs-npm-1.29.0-6faa5b04b8-007a8869d4.zip/node_modules/prismjs/components/index.js:1:33
    at instantiateModule (file:///my-blogster-blog/.yarn/__virtual__/vite-virtual-2b0880e296/0/cache/vite-npm-3.2.5-f23b9ecb5b-ad35b7008c.zip/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:53364:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5

Other information:

flexdinesh commented 1 year ago

Is this a yarn version issue? I tried with node@16, node@18 and node@19 in MacOS and things work as you'd expect them to. I'm on yarn v1. Perhaps one of the dependency has a problem with yarn v3. Could you try deleting node_modules and yarn.lock and try installing the dependencies using npm or even pnpm to see if the problem is really with yarn v3?

hut36 commented 1 year ago

Tried npm and yarn v1 and both worked. So this is perhaps a yarn version issue as you said. Thanks for help!

flexdinesh commented 1 year ago

Probably one (or a few) of the dependencies is not compatible with yarn 2/3 pnp - https://yarnpkg.com/features/pnp

ghost commented 1 year ago

This happens with PNPM too, however simply updating the packages to their latest version fixes this.