question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ParticlesJS is not defined

See original GitHub issue

Hello, I’ve been trying to get particles js to work with vuepress. On my config I have:

head: [
    ['script', {src: 'https://cdn.jsdelivr.net/npm/particles.js@2.0.0/particles.min.js'}]
]

It works when I run vuepress dev but as soon as I try to build with vuepress build I get the error saying ParticlesJS is not defined even though it is there and working.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
lindelofcommented, Dec 12, 2019
0reactions
ulivzcommented, Sep 22, 2019

If you have some scripts which rely on the loading script, it actually means that you are accessing window, which will offend the Browser API Access Restrictions

For solving your problem, you should install it at your project and externalize it:

yarn add particles.js -S
// .vuepress/config.js
module.exports = {
   chainWebpack(config) {
      config.externals({
         'particles.js': 'ParticlesJS'
      })
   }
}

In you client code, you should using es import instead of window.ParticlesJS:

import ParticlesJS from 'particles.js'
Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught ReferenceError: particlesJS is not defined
However, it stopped working today with no changes made to the site. The console says: Uncaught ReferenceError: particlesJS is not defined. We ...
Read more >
particlesJS not defined · Issue #218 · VincentGarreau/particles.js
Uncaught ReferenceError : particlesJS is not defined at (index):911 This is my Code:
Read more >
Particles.js error 'particlesJS' is not defined - Roots Discourse
I've been trying to integrate particles.js into my theme., however, I keep running into the error "error 'particlesJS' is not defined".
Read more >
PARTICLE.JS -- Uncaught ReferenceError: particlesJS is not ...
Basically the issue is that ParticleJS is undefined and won't load properly. this is the error I'm receiving: index.html:18 Uncaught ...
Read more >
tsparticles - npm
Not Bundle. This installation requires more work since all dependencies must be included in the page. Some lines above are all specified in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found