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

ModuleBuildError: Module build failed: TypeError: Cannot read property 'posts' of undefined #5

Open
dorelljames opened this issue Sep 20, 2017 · 7 comments

Comments

@dorelljames
Copy link

dorelljames commented Sep 20, 2017

  • Do you want to request a feature or report a bug?
    Bug

  • What is the current behavior?
    Build errors on compile. Cannot GET / in browser when viewing site.

  • If the current behavior is a bug, please provide the steps to reproduce.

I basically followed the instructions on readme. Installation via sprout or spike cli didn't worked. I also tried running this through node_modules/spike/bin/spike without success as well.

  1. npm i spike -g
  2. spike tpl add jekyll [email protected]:static-dev/spike-tpl-jekyll.git
  3. spike new -t jekyll
  4. npm start or spike watch or spike compile - all result to same error
  • What is the expected behavior?
    It should successfully compile and be able to browse the static compiled site.

  • Please mention your Spike version, and operating system version.
    Tested on the following:

    Latest version 2.2.0.
    Node version v.8.1.4
    CentOS release 6.6 (Final)

    Latest version 2.2.0.
    Node version v.6.8.1
    OS X El Capitan Version 10.11.6

  • Please provide build logs, error, etc.

[root@webriq-shop spikejekyll]# npm start

> [email protected] start /tmp/spikejekyll
> spike watch

✗ ERROR
{ ModuleBuildError: Module build failed: TypeError: Cannot read property 'posts' of undefined
    at eval (eval at module.exports (/tmp/spikejekyll/node_modules/reshape-code-gen/lib/scoped_eval.js:9:10), <anonymous>:1:711)
    at Object.eval (eval at module.exports (/tmp/spikejekyll/node_modules/reshape-code-gen/lib/scoped_eval.js:9:10), <anonymous>:1:948)
    at Object.eval [as output] (eval at module.exports (/tmp/spikejekyll/node_modules/reshape-code-gen/lib/scoped_eval.js:9:10), <anonymous>:1:1222)
    at reshape.process.then (/tmp/spikejekyll/node_modules/reshape-loader/lib/index.js:78:24)
    at tryCatchReject (/tmp/spikejekyll/node_modules/when/lib/makePromise.js:845:30)
    at runContinuation1 (/tmp/spikejekyll/node_modules/when/lib/makePromise.js:804:4)
    at Fulfilled.when (/tmp/spikejekyll/node_modules/when/lib/makePromise.js:592:4)
    at Pending.run (/tmp/spikejekyll/node_modules/when/lib/makePromise.js:483:13)
    at Scheduler._drain (/tmp/spikejekyll/node_modules/when/lib/Scheduler.js:62:19)
    at Scheduler.drain (/tmp/spikejekyll/node_modules/when/lib/Scheduler.js:27:9)
    at runLoaders (/tmp/spikejekyll/node_modules/webpack/lib/NormalModule.js:192:19)
    at /tmp/spikejekyll/node_modules/loader-runner/lib/LoaderRunner.js:364:11
    at /tmp/spikejekyll/node_modules/loader-runner/lib/LoaderRunner.js:230:18
    at context.callback (/tmp/spikejekyll/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at tryCatchReject (/tmp/spikejekyll/node_modules/when/lib/makePromise.js:845:30)
    at runContinuation1 (/tmp/spikejekyll/node_modules/when/lib/makePromise.js:804:4)
    at Rejected.when (/tmp/spikejekyll/node_modules/when/lib/makePromise.js:625:4)
    at Pending.run (/tmp/spikejekyll/node_modules/when/lib/makePromise.js:483:13)
    at Scheduler._drain (/tmp/spikejekyll/node_modules/when/lib/Scheduler.js:62:19)
    at Scheduler.drain (/tmp/spikejekyll/node_modules/when/lib/Scheduler.js:27:9) id: '902aae7e' }
⚠ WARNING
{ ModuleBuildError: Module build failed: TypeError: Cannot read property 'posts' of undefined
    at eval (eval at module.exports (/tmp/spikejekyll/node_modules/reshape-code-gen/lib/scoped_eval.js:9:10), <anonymous>:1:711)
    at Object.eval (eval at module.exports (/tmp/spikejekyll/node_modules/reshape-code-gen/lib/scoped_eval.js:9:10), <anonymous>:1:948)
    at Object.eval [as output] (eval at module.exports (/tmp/spikejekyll/node_modules/reshape-code-gen/lib/scoped_eval.js:9:10), <anonymous>:1:1222)
    at reshape.process.then (/tmp/spikejekyll/node_modules/reshape-loader/lib/index.js:78:24)
    at tryCatchReject (/tmp/spikejekyll/node_modules/when/lib/makePromise.js:845:30)
    at runContinuation1 (/tmp/spikejekyll/node_modules/when/lib/makePromise.js:804:4)
    at Fulfilled.when (/tmp/spikejekyll/node_modules/when/lib/makePromise.js:592:4)
    at Pending.run (/tmp/spikejekyll/node_modules/when/lib/makePromise.js:483:13)
    at Scheduler._drain (/tmp/spikejekyll/node_modules/when/lib/Scheduler.js:62:19)
    at Scheduler.drain (/tmp/spikejekyll/node_modules/when/lib/Scheduler.js:27:9)
    at runLoaders (/tmp/spikejekyll/node_modules/webpack/lib/NormalModule.js:192:19)
    at /tmp/spikejekyll/node_modules/loader-runner/lib/LoaderRunner.js:364:11
    at /tmp/spikejekyll/node_modules/loader-runner/lib/LoaderRunner.js:230:18
    at context.callback (/tmp/spikejekyll/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
    at tryCatchReject (/tmp/spikejekyll/node_modules/when/lib/makePromise.js:845:30)
    at runContinuation1 (/tmp/spikejekyll/node_modules/when/lib/makePromise.js:804:4)
    at Rejected.when (/tmp/spikejekyll/node_modules/when/lib/makePromise.js:625:4)
    at Pending.run (/tmp/spikejekyll/node_modules/when/lib/makePromise.js:483:13)
    at Scheduler._drain (/tmp/spikejekyll/node_modules/when/lib/Scheduler.js:62:19)
    at Scheduler.drain (/tmp/spikejekyll/node_modules/when/lib/Scheduler.js:27:9) id: '902aae7e' }
compiled (0.975s)
▸ External IP: http://127.0.0.1:1111
@garywu
Copy link

garywu commented Sep 20, 2017

Same problem here will poke a little.

@dorelljames
Copy link
Author

dorelljames commented Sep 21, 2017

So I've found a workaround. :)

In index.sgr instead of:

ul
      each(loop='post in _pages.posts[0].posts')
        li
          a(href='{{ post._path }}') {{ post.title }}

    if(condition='_pages.posts[1]')
      a(href='{{ _pages.posts[1].path }}') Next Page &raquo;

change it to:

ul
      each(loop='post in _collections.posts')
        li
          a(href='{{ post._path }}') {{ post.title }}

    if(condition='_pages.posts[1]')
      a(href='{{ _pages.posts[1].path }}') Next Page &raquo;

The above will still result in an error because of the breaking changes of spike-collections on paginations so you need to update to latest spike version in order for it to work or remove the lines pertaining to pagination so that it'll be like this below:

ul
      each(loop='post in _collections.posts')
        li
          a(href='{{ post._path }}') {{ post.title }}

When I tried updating to latest Spike version 2.2, I encountered another error pertaining to No dependency factory available for this dependency type: MultiEntryDependency. It seems to be a webpack issue.

@jescalan
Copy link
Member

Ah sorry, that's an issue with this template, which clearly has not been updated recently enough. You can remove webpack from your package.json and reinstall dependencies to resolve this.

@jescalan
Copy link
Member

Confirmed that this is a bug, working on a fix

@jescalan
Copy link
Member

In progress here: #6

@dvc94ch
Copy link

dvc94ch commented May 20, 2018

ping @jescalan: guessing you forgot about this... :)

@jescalan
Copy link
Member

Yeah, I'm sorry I just do not have the bandwidth to complete this right now 😢

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

4 participants