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

"Cannot read property 'version' of undefined" when running harp compile #370

Closed
PandaWhisperer opened this issue Oct 27, 2014 · 3 comments
Closed

Comments

@PandaWhisperer
Copy link

Getting this strange error when running harp compile in my project.

{
  "source": "Jade",
  "dest": "HTML",
  "filename": "./node_modules/harp/lib/templates/_layout.jade",
  "lineno": 129,
  "name": "TypeError",
  "message": "Cannot read property 'version' of undefined",
  "stack": "doctype\nhtml(lang=\"en\")\n\thead\n\t\tmeta(charset=\"utf-8\")\n\t\tmeta(http-equiv=\"X-UA-Compatible\", content=\"IE=edge,chrome=1\")\n\t\t//- title #{ pkg.name } #{ pkg.version }\n\t\ttitle Harp\n\t\tmeta(name=\"handheldfriendly\", content=\"true\")\n\t\tmeta(name=\"mobileoptimized\", content=\"320\")\n\t\tmeta(name=\"viewport\", content=\"width=device-width, initial-scale=1.0\")\n\t\tmeta(http-equiv=\"cleartype\", content=\"on\")\n\t\tstyle.\n\t\t\tbody {\n\t\t\t\tfont-family: Verdana;\n\t\t\t\tpadding:10px 10px;\n\t\t\t}\n\n\t\t\th1, h2, h3, h4, h5, h6{\n\t\t\t\tfont-weight: 300;\n\t\t\t\tline-height: 1.5em;\n\t\t\t}\n\n\t\t\th3 {\n\t\t\t\tfont-weight: 500;\n\t\t\t\tfont-size: 1em;\n\t\t\t}\n\n\t\t\tp {\n\t\t\t\tfont-size: 1em;\n\t\t\t\tline-height: 1.5em;\n\t\t\t}\n\n\t\t\theader{\n\t\t\t\tpadding:20px 0px;\n\t\t\t}\n\n\t\t\theader h1{\n\t\t\t\tmargin:0;\n\t\t\t}\n\n\t\t\theader h3{\n\t\t\t\tmargin:0;\n\t\t\t}\n\n\t\t\t.stacktrace{\n\t\t\t\tpadding:0px;\n\t\t\t\tmargin-bottom:20px;\n\t\t\t\tmargin-top:40px;\n\t\t\t\tborder:2px solid #a44;\n\t\t\t\tbackground:#a44;\n\t\t\t}\n\n\t\t\t.stacktrace h3{\n\t\t\t\tpadding:22px 0px 20px 10px;\n\t\t\t\tcolor: #fff;\n\t\t\t\tmargin:0px;\n\t\t\t\tfont-size:0.75em;\n\t\t\t\tline-height:1em;\n\t\t\t\tfont-weight:600;\n\t\t\t\toverflow:auto;\n\t\t\t}\n\n\t\t\tpre {\n\t\t\t\tpadding: 20px 0px;\n\t\t\t\tmargin:0;\n\t\t\t\tbackground:#f8f8f8;\n\t\t\t\twidth:100%;\n\t\t\t\toverflow:auto;\n\t\t\t}\n\n\t\t\tcode{\n\t\t\t\tline-height: 1.5em;\n\t\t\t\tfont-size: 1em;\n\t\t\t}\n\n\t\t\tfooter{\n\t\t\t\tbackground: #f8f8f8;\n\t\t\t\tpadding:20px 0px 20px 20px;\n\t\t\t\tborder-top:2px solid #eee;\n\t\t\t}\n\n\t\t\t.version{\n\t\t\t\tbackground: #6b919e;\n\t\t\t\tpadding: 2px 6px;\n\t\t\t\tborder-radius: 3px;\n\t\t\t\tcolor:#FFF;\n\t\t\t\tfont-weight: 300;\n\t\t\t}\n\n\t\t\tul.projects {\n\t\t\t\tpadding: 0;\n\t\t\t}\n\n\t\t\tul.projects li{\n\t\t\t\tlist-style-type:none;\n\t\t\t\tmargin-bottom:10px;\n\t\t\t}\n\n\t\t\tul.projects li a{\n\t\t\t\tbackground: #eee;\n\t\t\t\tpadding:25px 0px 25px 20px;\n\t\t\t\tborder-left: 4px solid #6b919e;\n\t\t\t\tdisplay:block;\n\t\t\t\tborder-radius: 5px;\n\t\t\t\ttext-decoration:none;\n\t\t\t}\n\n\t\t\tul.projects li a h2{\n\t\t\t\tfont-weight:bold;\n\t\t\t\tcolor: #6b919e;\n\t\t\t\tmargin:0px;\n\t\t\t}\n\n\t\t\tul.projects li a code{\n\t\t\t\tmargin:0px;\n\t\t\t\tcolor:#666;\n\t\t\t\ttext-decoration:none;\n\t\t\t}\n\n\t\t\t.center {\n\t\t\t\ttext-align:center;\n\t\t\t\tpadding-top: 100px;\n\t\t\t\tpadding-bottom: 100px;\n\t\t\t}\n\n\tbody\n\t\t!= yield\n\t\tfooter\n\t\t\tp Harp <span class=\"version\">v#{ pkg.version }</span> &nbsp;\n\t\t\t\ta(href=\"http://harpjs.com/docs/\", target=\"_blank\") Documentation\n"
}

I'm not quite sure why it's reporting an error in ./node_modules/harp/lib/templates/_layout.jade. My project does have a _layout.jade in the main directory.

@kennethormandy
Copy link
Collaborator

Oh, it looks like you might have installed Harp locally by mistake, so Harp is trying to compile its own default _layout.jade. Instead of including Harp as a dependency in your package.json (which is really only necessary if you’re using it as middleware), you could add “Install Harp with npm install -g harp to the project Readme.

I’m going to close this, but feel free to post again if you have any more questions about this. Thanks for opening an issue!

@PandaWhisperer
Copy link
Author

I see. It looks like Harp is trying to compile everything in node_modules. I'm getting an error from a different package now that includes some stylesheets.

Is there any way to exclude that directory from harp compile, or do I have to move all the assets I want to compile to a public subdirectory and just compile that?

@kennethormandy
Copy link
Collaborator

There’s a PR for that #312 but it breaks many tests. If someone fixes that, I think we might be able to merge it. Otherwise, it’ll be something that gets figured out as part of adding Browserify support, which is also planned.

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