Ty3uK/parcel-plugin-pug

Path must be a string. Received undefined

gisderdube opened this issue · 9 comments

Hi there,

I'm trying to get parcel to work with pug files. I tried setting up a test project with test.pug with the following content

html
    head
    body
        h1 Hello

package.json is as followed:

{
  "name": "parcel",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "parcel-plugin-pug": "^0.2.4"
  },
  "devDependencies": {
    "parcel-bundler": "^1.5.1"
  }
}

I get the following error:

MacBook-Pro:parcel gisderdube$ parcel test.pug
⏳  Building...
Server running at http://localhost:1234 
🚨  Path must be a string. Received undefined
    at assertPath (path.js:28:11)
    at Object.relative (path.js:1261:5)
    at new Asset (/Users/gisderdube/Documents/hacking.nosync/parcel/node_modules/parcel-bundler/src/Asset.js:22:30)
    at new PugAsset (/Users/gisderdube/Documents/hacking.nosync/parcel/node_modules/parcel-plugin-pug/build/PugAsset.js:32:9)
    at Parser.getAsset (/usr/local/lib/node_modules/parcel-bundler/src/Parser.js:61:12)
    at Bundler.resolveAsset (/usr/local/lib/node_modules/parcel-bundler/src/Bundler.js:261:29)
    at <anonymous>

running on OSX v10.13.2 (17C205) and node.js v8.9.4

Any suggestions here?

Ty3uK commented

I’ll check this later, thanks for feedback 🤝

Ty3uK commented

@gisderdube checked your issue and only one error that I've got is a

🚨asset.shouldInvalidate is not a function
    at Bundler.loadAsset (/Users/ty3uk/projects/js/parcel-test/node_modules/parcel-bundler/src/Bundler.js:370:29)
    at <anonymous>

Fixed this error in 0.2.5

I am getting the same error. If I do nothing more than create an index.pug file and install parcel-plugin-pug and parcel-bundler, running parcel index.pug errors out with the following message:

🚨  Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.relative (path.js:1233:5)
    at PugAsset.Asset (/Users/caleb/Sites/parcel-pug-test/node_modules/parcel-bundler/lib/Asset.js:27:30)
    at PugAsset (/Users/caleb/Sites/parcel-pug-test/node_modules/parcel-plugin-pug/build/PugAsset.js:32:9)
    at Parser.getAsset (/Users/caleb/.yarn-cache/.global/node_modules/parcel-bundler/lib/Parser.js:68:12)
    at /Users/caleb/.yarn-cache/.global/node_modules/parcel-bundler/lib/Bundler.js:332:33
    at next (native)
    at step (/Users/caleb/.yarn-cache/.global/node_modules/parcel-bundler/lib/Bundler.js:3:191)
    at /Users/caleb/.yarn-cache/.global/node_modules/parcel-bundler/lib/Bundler.js:3:361

Here is my package.json file:

{
  "name": "parcel-pug-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "parcel-bundler": "^1.6.2",
    "parcel-plugin-pug": "^0.2.5"
  }
}

index.pug:

html
	body
		script(src='./index.js')

index.js:

console.log("hello world");

Ty3uK commented

Issue has been resolved after updating internal dependencies to latest versions

jt3k commented

now i have same problem

node -v && npm -v && parcel --version
v10.0.0
6.0.0
1.9.2

I experience it too 😿
node -v && npm -v && parcel --version v8.11.2 6.0.1 1.9.4

EDIT: Ok so after I discovered that this is deprecated and integrated with Parcel, I just run npm uninstall parcel-plugin-pug and rebuilt the project. Pug 2.0.3 was installed automatically and everything is fine 👍

I experience it too 😿
node -v && npm -v && parcel --version v8.11.2 6.0.1 1.9.4

EDIT: Ok so after I discovered that this is deprecated and integrated with Parcel, I just run npm uninstall parcel-plugin-pug and rebuilt the project. Pug 2.0.3 was installed automatically and everything is fine 👍

Thank you deeply. 🙏

I experience it too 😿
node -v && npm -v && parcel --version v8.11.2 6.0.1 1.9.4

EDIT: Ok so after I discovered that this is deprecated and integrated with Parcel, I just run npm uninstall parcel-plugin-pug and rebuilt the project. Pug 2.0.3 was installed automatically and everything is fine 👍

OMG, I got same error again. Did you installed parcel-bundler into your repository? I did it and got same error or got "Cannot find module 'parcel-bundler/src/Asset'". How did you solved this problem?

Ty3uK commented

@mrcooder Try to update parcel to latest version and remove plugin (important step!)