Gatsby: [1.0] TypeError: Cannot read property 'component---src-pages-index-js' of undefined

Created on 14 Jun 2018  Â·  18Comments  Â·  Source: gatsbyjs/gatsby

Description

1 npm i -S gatsby -g
2 gatsby new gatsby-test
3 cd gatsby-test
4 gatsby develop

*im on a windows computer at work, and the location of the global installation (from what I can tell, im not THE most savvy, im a self-taught programmer) is in: C:\Users\[username]\AppData\Roaming\npm\node_modules

Steps to reproduce

same as description... this is just simply trying to run the gatsby develop script on the basic as-is 'new' gatsby project

Expected result

should run on localhost:8000

Actual result

Receive the following text @ localhost:8000

TypeError: Cannot read property 'component---src-pages-index-js' of undefined

fetchResource
C:/Users/fnarbona/.atom/projects/gatsby-test/.cache/loader.js:77

74 | // Find resource
75 | let resourceFunction
76 | if (resourceName.slice(0, 12) === component---) {

77 | resourceFunction = asyncRequires.components[resourceName]
78 | } else if (resourceName.slice(0, 9) === layout---) {
79 | resourceFunction = asyncRequires.layouts[resourceName]
80 | } else {

View compiled

getResourceModule
C:/Users/fnarbona/.atom/projects/gatsby-test/.cache/loader.js:112

109 | cb(failedResources[resourceName])
110 | })
111 | } else {

112 | fetchResource(resourceName, (err, executeChunk) => {
113 | if (err) {
114 | cb(err)
115 | } else {

View compiled

getResourcesForPathname
C:/Users/fnarbona/.atom/projects/gatsby-test/.cache/loader.js:358

355 | })
356 | }
357 | }

358 | getResourceModule(page.componentChunkName, (err, c) => {
359 | if (err) {
360 | handleResourceLoadError(
361 | page.path,

View compiled

new ComponentRenderer
C:/Users/fnarbona/.atom/projects/gatsby-test/.cache/component-renderer.js:27

24 |
25 | this.state = {
26 | location,

27 | pageResources: loader.getResourcesForPathname(location.pathname),
28 | }
29 | }
30 |

View compiled

â–¶ 43 stack frames were collapsed.

(anonymous function)
C:/Users/fnarbona/.atom/projects/gatsby-test/.cache/app.js:42

39 | Root = Root.default
40 | }
41 |

42 | domReady(() =>
43 | ReactDOM.render(
44 |
45 |

View compiled

HTMLDocument.listener
C:/Users/fnarbona/.atom/projects/gatsby-test/node_modules/domready/ready.js:23

Environment

PS C:\Users\fnarbona.atom\projects\gatsby-test> gatsby info --clipboard

System:
OS: Windows 7
CPU: x64 Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
Binaries:
npm: 5.6.0 - C:\Program Files\nodejs\npm.CMD
npmPackages:
gatsby: ^1.9.247 => 1.9.250
gatsby-link: ^1.6.40 => 1.6.40
gatsby-plugin-react-helmet: ^2.0.10 => 2.0.10

error The system cannot find the path specified.

Error: The system cannot find the path specified.

  • envinfo.js:1 Function.e.exports.sync
    [npm]/[gatsby]/[envinfo]/dist/envinfo.js:1:7778

  • envinfo.js:1 Object.copySync
    [npm]/[gatsby]/[envinfo]/dist/envinfo.js:1:104976

  • envinfo.js:1 Object.t.writeSync.e [as writeSync]
    [npm]/[gatsby]/[envinfo]/dist/envinfo.js:1:123499

  • envinfo.js:1
    [npm]/[gatsby]/[envinfo]/dist/envinfo.js:1:124274

  • envinfo.js:1 Promise.all.then.e
    [npm]/[gatsby]/[envinfo]/dist/envinfo.js:1:124289

  • util.js:16 tryCatcher
    [npm]/[gatsby]/[bluebird]/js/release/util.js:16:23

  • promise.js:512 Promise._settlePromiseFromHandler
    [npm]/[gatsby]/[bluebird]/js/release/promise.js:512:31

  • promise.js:569 Promise._settlePromise
    [npm]/[gatsby]/[bluebird]/js/release/promise.js:569:18

  • promise.js:614 Promise._settlePromise0
    [npm]/[gatsby]/[bluebird]/js/release/promise.js:614:10

  • promise.js:693 Promise._settlePromises
    [npm]/[gatsby]/[bluebird]/js/release/promise.js:693:18

  • promise.js:638 Promise._fulfill
    [npm]/[gatsby]/[bluebird]/js/release/promise.js:638:18

  • promise_array.js:126 PromiseArray._resolve
    [npm]/[gatsby]/[bluebird]/js/release/promise_array.js:126:19

  • promise_array.js:144 PromiseArray._promiseFulfilled
    [npm]/[gatsby]/[bluebird]/js/release/promise_array.js:144:14

  • promise.js:574 Promise._settlePromise
    [npm]/[gatsby]/[bluebird]/js/release/promise.js:574:26

  • promise.js:614 Promise._settlePromise0
    [npm]/[gatsby]/[bluebird]/js/release/promise.js:614:10

  • promise.js:693 Promise._settlePromises
    [npm]/[gatsby]/[bluebird]/js/release/promise.js:693:18

error UNHANDLED REJECTION

Error: The system cannot find the path specified.

  • envinfo.js:1 Function.e.exports.sync
    [npm]/[gatsby]/[envinfo]/dist/envinfo.js:1:7778

  • envinfo.js:1 Object.copySync
    [npm]/[gatsby]/[envinfo]/dist/envinfo.js:1:104976

  • envinfo.js:1 Object.t.writeSync.e [as writeSync]
    [npm]/[gatsby]/[envinfo]/dist/envinfo.js:1:123499

  • envinfo.js:1
    [npm]/[gatsby]/[envinfo]/dist/envinfo.js:1:124274

  • envinfo.js:1 Promise.all.then.e
    [npm]/[gatsby]/[envinfo]/dist/envinfo.js:1:124289

  • util.js:16 tryCatcher
    [npm]/[gatsby]/[bluebird]/js/release/util.js:16:23

  • promise.js:512 Promise._settlePromiseFromHandler
    [npm]/[gatsby]/[bluebird]/js/release/promise.js:512:31

  • promise.js:569 Promise._settlePromise
    [npm]/[gatsby]/[bluebird]/js/release/promise.js:569:18

  • promise.js:614 Promise._settlePromise0
    [npm]/[gatsby]/[bluebird]/js/release/promise.js:614:10

  • promise.js:693 Promise._settlePromises
    [npm]/[gatsby]/[bluebird]/js/release/promise.js:693:18

  • promise.js:638 Promise._fulfill
    [npm]/[gatsby]/[bluebird]/js/release/promise.js:638:18

  • promise_array.js:126 PromiseArray._resolve
    [npm]/[gatsby]/[bluebird]/js/release/promise_array.js:126:19

  • promise_array.js:144 PromiseArray._promiseFulfilled
    [npm]/[gatsby]/[bluebird]/js/release/promise_array.js:144:14

  • promise.js:574 Promise._settlePromise
    [npm]/[gatsby]/[bluebird]/js/release/promise.js:574:26

  • promise.js:614 Promise._settlePromise0
    [npm]/[gatsby]/[bluebird]/js/release/promise.js:614:10

  • promise.js:693 Promise._settlePromises
    [npm]/[gatsby]/[bluebird]/js/release/promise.js:693:18

File contents (if changed)

gatsby-config.js: N/A
package.json: N/A
gatsby-node.js: N/A
gatsby-browser.js: N/A
gatsby-ssr.js: N/A

stale? question or discussion

Most helpful comment

For those who solved the problem by changing port: Clearing the browser cache (I'm using chrome) fixed the issue for me without changing port.

All 18 comments

Hmm this seems odd, looks like missing files or a permissions issue? Gatsby should be fine on Windows. What happens if you try gatsby new another-test and try again?

I get the same error. Did you find a fix or a workaround for that?

[EDIT]:

I tried removing any of my custom written components until I ended up at the starter boilerplate and I still got the same error. I then checked if I could run the boilerplate which is generated with gatsby new projectname and still got the error. I even tried uninstalling gatsby with npm uninstall -g gatsby-cli and installing the windows-build-tools via npm and still got the error.

Old issues will be closed after 30 days of inactivity. This issue has been quiet for 20 days and is being marked as stale. Reply here or add the label "not stale" to keep this issue open!

This issue is being closed due to inactivity. Is this a mistake? Please re-open this issue or create a new issue.

I am facing the same issue. Repo can be found here. Interesting thing is that it builds the site successfully but it is unable to generate the development version of the site.

I faced similar issue. I fixed it by following below steps.

  1. Delete .cache file.
  2. gatsby build.
  3. gatsby serve. It was working fine here.

Continued with development with gatsby develop.

For me the problem wasn't the final build, but the error spun up during the Gatsby develop command. I worked around the issue by specifying a new port instead of port 8000 and it for some reason worked.

For me the problem happened just after my first gatsby build.
And like @tristankrass , changing the port fixed the issue. 8001 to 8000.

I also solved the problem by switching out the port... makes no sense.

For me this also happened after a build.
Switching port also worked for me somehow...I can see my project again without errors.
But now when I do any changes, nothing happens... Its neither hot reloading than working on page refresh... Have no idea how to work on the site now...

This is started happening to me too... And the only thing that worked was changing the dev port. I restarted my computer and no luck.

For those who solved the problem by changing port: Clearing the browser cache (I'm using chrome) fixed the issue for me without changing port.

I second @jonny5 's answer. But rather than clearing the entire browser's cache, you can just open developer tools and click "clear site data" from Applications tab.

I second @jonny5 's answer. But rather than clearing the entire browser's cache, you can just open developer tools and click "clear site data" from Applications tab.

I've tried removing .cache folder and rebuild but still doesn't work. but This solution works for me. just clear site data. Thank you @prajapati-parth

Also just had this issue. Clearing site data worked for me!

Clearing the site data worked.

It started happening to me when PWA and offline caching is enabled. The page simply keeps reloading indefinitely. I had to click Ctrl+Shft+R every time to see the changes. After clearing the Application Storage in Chrome dev tools, it started working.

On Chrome, open your browser's console on that page, right click on the reload button and choose:
Empty Cache and Hard Reload

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandonmp picture brandonmp  Â·  3Comments

dustinhorton picture dustinhorton  Â·  3Comments

kalinchernev picture kalinchernev  Â·  3Comments

3CordGuy picture 3CordGuy  Â·  3Comments

magicly picture magicly  Â·  3Comments