# ReferenceError: path is not defined

**URL:** <https://discourse.processing.org/t/referenceerror-path-is-not-defined/34519>\
**Category:** Coding Questions\
**Created:** [January 8, 2022, 2:30am UTC](https://discourse.processing.org/t/referenceerror-path-is-not-defined/34519 "2022-01-08T02:30:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Errorbot1122](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/errorbot1122/32/14718_2.png) [@Errorbot1122](https://discourse.processing.org/u/Errorbot1122)\
**Post date:** [January 8, 2022, 2:30am UTC](https://discourse.processing.org/t/referenceerror-path-is-not-defined/34519/1 "2022-01-08T02:30:04Z")

</div>

Whenever I run my code I get this error

```auto
ReferenceError: path is not defined
    at https://365155ea-fe08-466f-b1bf-6d6d9500167a.id.repl.co/loading.js:122:67
    at new Promise (<anonymous>)
    at https://365155ea-fe08-466f-b1bf-6d6d9500167a.id.repl.co/loading.js:122:21
    at Array.forEach (<anonymous>)
    at loadFile (https://365155ea-fe08-466f-b1bf-6d6d9500167a.id.repl.co/loading.js:29:9)
    at _.p.setup (https://365155ea-fe08-466f-b1bf-6d6d9500167a.id.repl.co/loading.js:153:2)
    at _setup (https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.min.js:3:423972)
    at _start (https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.min.js:3:422871)

```

This is the code snippet I think might be causing the problem

```auto
case 'png':
case 'jpg':
case 'jpeg':
case 'gif':

	if (lib === 'p5') {
		// This code... V
		returnObj.p5 = new Promise((resolve, reject) => {p.loadImage(fileObj.path, resolve, reject)})
	}
	else if (lib === '3js') {
		returnObj.three = new THREE.ImageLoader(threeLoadingManager).load(fileObj.path, threeSuccessCallback, undifined, failureCallback)
	}

	break;

	// ...

```

  

**`fileObj`** is this: `{ path: 'BRUH.png', forLib: ['p5'] }` for testing

**Also, I’m running p5 in instance mode RN**

This is the code that is running the function:

```auto
p.setup = () => {
	loadFile(filesToLoad[0], p).p5.then(console.log).catch(console.error)
	console.log(filesToLoad[0])
	// ...

```

My full code is currently hosted on [repl.it](https://replit.com/@ErrorbotTHE2nd/Roblox-External-Editor#loading.js)

---

<div class="post-metadata">

**Author:** ![KumuPaul](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kumupaul/32/13072_2.png) [@KumuPaul](https://discourse.processing.org/u/KumuPaul)\
**Post date:** [January 8, 2022, 8:32am UTC](https://discourse.processing.org/t/referenceerror-path-is-not-defined/34519/2 "2022-01-08T08:32:58Z")

</div>

Some of your case statements are using just `path` instead of `fileObj.path`:

```auto

			// Font
			case 'otf':
			case 'ttf':

				if (lib === 'p5') {
					returnObj.p5 = new Promise((resolve, reject) => {p.loadFont(path, resolve, reject)})
				}
				break;
			
			// Raw Data (Bytes)
			default:

				if (lib === 'p5') {
					returnObj.p5 = new Promise((resolve, reject) => {p.loadBytes(path, resolve, reject)})
				}
				break;

```

---

<div class="post-metadata">

**Author:** ![Errorbot1122](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/errorbot1122/32/14718_2.png) [@Errorbot1122](https://discourse.processing.org/u/Errorbot1122)\
**Post date:** [January 10, 2022, 4:18am UTC](https://discourse.processing.org/t/referenceerror-path-is-not-defined/34519/3 "2022-01-10T04:18:14Z")

</div>

Oh… That was dumb…  
THANK YOU 🙂
