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.

p5 is not defined when trying to use p5.js-sound in v1.0.0

See original GitHub issue
Uncaught ReferenceError: p5 is not defined
    at Object.eval (p5.sound.js?e617:3112)
    at Object.eval (p5.sound.js?e617:3160)
    at __webpack_require__ (p5.sound.js?e617:84)
    at Object.eval (p5.sound.js?e617:2885)
    at Object.eval (p5.sound.js?e617:2956)
    at __webpack_require__ (p5.sound.js?e617:84)
    at eval (p5.sound.js?e617:120)
    at eval (p5.sound.js?e617:122)
    at Object../node_modules/p5/lib/addons/p5.sound.js (chunk-vendors.js:7513)
    at __webpack_require__ (app.js:785)

Getting this error after updating to p5@1.0.0 from p5@0.9.0 in Quasar Vue via NMP.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:11
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
rjbultitudecommented, Mar 4, 2021

Hi @aceslowman Not sure why this issue was closed when the problem persists.

I can confirm it is not a problem with Webpack - the problem exists in all modern module loaders/compilers including RollUp, TypeScript and Parcel.

Having tested more thoroughly, I can confirm P5 add-ons won’t load in the following configurations:

  • CommonJS
  • ES6 > ES5 using Babel or esm
  • ES Modules

Given the enournous populariity of npm and yarn, this issue means that anyone using those package managers will not be able to use p5 with add-ons.

The suggestions to manually overwrite files saved to node_modules are totally unsustainable - as soon as you install again (locally, or in CI) it will be overwritten.

I see the same issue exists with p5 dom, as is expressed here: https://github.com/processing/p5.js/issues/4479

What was it that changed between v0.9 and v1 that broke it?

8reactions
aceslowmancommented, Aug 5, 2020

I’m unable to get p5.sound to work with p5 (v1.1.9) using npm and can’t seem to get @vanyamil 's solution to work. After downgrading to 0.9, copying over the p5.sound.js to the project directory, then upgrading to latest, it still returns errors.

I am importing with:

import p5 from 'p5';
import './lib/p5.sound.js';
---
this.mic = new p5.AudioIn();

And I receive the following error:

Failed to compile.

./src/lib/p5.sound.js
  Line 68:39:    'define' is not defined                                                no-undef
  Line 69:5:     'define' is not defined                                                no-undef
  Line 77:1:     Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 999:1:    Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 1097:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 1207:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 1506:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 1545:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 1638:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 1902:13:  Unexpected use of 'onerror'                                            no-restricted-globals
  Line 1903:11:  Unexpected use of 'onerror'                                            no-restricted-globals
  Line 2780:12:  Unexpected use of 'self'                                               no-restricted-globals
  Line 3154:24:  Unexpected use of 'self'                                               no-restricted-globals
  Line 3176:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 3455:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 3748:7:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 3749:7:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 5215:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 5363:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 6309:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 7111:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 7290:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 7436:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 8245:15:  Unexpected use of 'name'                                               no-restricted-globals
  Line 8353:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 8495:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 8775:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 8825:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 9017:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 9249:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 9468:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 9745:1:   Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 10373:1:  Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 10456:1:  Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 10902:7:  Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 10941:1:  Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 11411:1:  Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 11653:1:  Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 11876:1:  Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 12017:1:  Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 12067:1:  Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 12357:1:  Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 12748:1:  Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 12874:1:  Expected an assignment or function call and instead saw an expression  no-unused-expressions

I’m not sure if there is a short term fix to apply or if this error is due to my node environment. Is p5.sound.js an AMD module that my webpack config is having trouble with?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use p5.js sound in instance mode - Stack Overflow
The problem is that i can't find a way to use sound in my sketch using instance mode. the code i have is...
Read more >
Audio Tips 'n Tricks - OpenProcessing
This is an ongoing tutorial to help people with the p5.sound library.
Read more >
reference | p5.SoundFile - P5.js
Description. SoundFile object with a path to a file. The p5.SoundFile may not be available immediately because it loads the file information asynchronously....
Read more >
Untitled page - Zhijun Song - Cargo
https://cdn.jsdelivr.net/npm/p5@0.5.16/lib/addons/p5.sound.min.js can not be loaded. Please make sure resource exists and it supports cross-domain requests.
Read more >
Web Audio API - W3C
If the audio or video type pattern matching algorithm returns undefined , set can decode to false. If can decode is true, attempt...
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