Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

require is not defined #7

Open
hut36 opened this issue Jan 16, 2023 · 4 comments
Open

require is not defined #7

hut36 opened this issue Jan 16, 2023 · 4 comments

Comments

@hut36
Copy link

hut36 commented Jan 16, 2023

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:

  • platform: MacOS
  • yarn 3.3.0
  • node 18.12.1
@flexdinesh
Copy link
Owner

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
Copy link
Author

hut36 commented Jan 17, 2023

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

@flexdinesh
Copy link
Owner

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

@ghost
Copy link

ghost commented May 16, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants