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

Unexpected token u in JSON at position 0 #71

Open
receter opened this issue Apr 27, 2021 · 3 comments
Open

Unexpected token u in JSON at position 0 #71

receter opened this issue Apr 27, 2021 · 3 comments

Comments

@receter
Copy link

receter commented Apr 27, 2021

I updated my project to Gatsby 3 and can’t start the dev server unless I disable gatsby-plugin-favicon.

I am on Windows with WSL 2, this is the error that comes up if I try to start:

verbose Transition to "runningQueries" > "waitingForJobs"
verbose Transition to "runningQueries" > "done"
verbose Transition to "startingDevServers"

 ERROR 

(node:8994) [DEP_WEBPACK_COMPILATION_CACHE] DeprecationWarning: Compilation.cache was removed in favor of Compilation.getCache()
(Use `node --trace-deprecation ...` to show where the warning was created)


 ERROR 

(node:8994) [DEP_WEBPACK_COMPILATION_OPTIMIZE_CHUNK_ASSETS] DeprecationWarning: optimizeChunkAssets is deprecated (use Compilation.hooks.processAssets instead and use one of
Compilation.PROCESS_ASSETS_STAGE_* as stage option)

⠦ Building development bundle
/home/.../node_modules/yoga-layout-prebuilt/yoga-layout/build/Release/nbind.js:53
        throw ex;
        ^

SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at /home/.../node_modules/favicons-webpack-plugin/lib/compiler.js:115:23
    at /home/.../node_modules/webpack/lib/Compiler.js:534:11
    at /home/.../node_modules/webpack/lib/Compiler.js:1089:17
    at Hook.eval [as callAsync] (eval at create (/home/.../node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/.../node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
    at /home/.../node_modules/webpack/lib/Compiler.js:1085:33
    at /home/.../node_modules/webpack/lib/Compilation.js:2496:11
    at Hook.eval [as callAsync] (eval at create (/home/.../node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/.../node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
    at /home/.../node_modules/webpack/lib/Compilation.js:2489:38
    at eval (eval at create (/home/.../node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at /home/.../node_modules/webpack/lib/Compilation.js:468:10
    at /home/.../node_modules/webpack/lib/SourceMapDevToolPlugin.js:546:10
    at /home/.../node_modules/neo-async/async.js:2830:7
    at Object.each (/home/.../node_modules/neo-async/async.js:2857:9)```

My packages:

```  "dependencies": {
    "@wyze/gatsby-source-graphql": "^1.2.0",
    "gatsby": "^3.3.1",
    "gatsby-cli": "^3.3.0",
    "gatsby-plugin-env-variables": "^2.1.0",
    "gatsby-plugin-favicon": "^3.1.6",
    "gatsby-plugin-google-tagmanager": "^3.3.0",
    "gatsby-plugin-i18n": "^1.0.1",
    "gatsby-plugin-netlify": "^3.3.0",
    "gatsby-plugin-react-helmet": "^4.3.0",
    "gatsby-plugin-sass": "^4.3.0",
    "gatsby-source-filesystem": "^3.3.0",
    "gatsby-source-iubenda": "^1.0.2",
    "gatsby-source-strapi": "0.0.12",
    "intl": "^1.2.5",
    "node-sass": "^4.14.1",
    "prop-types": "^15.7.2",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-helmet": "^6.1.0",
    "react-intl": "^4.7.6",
    "react-player": "^2.9.0",
    "react-slick": "^0.23.2",
    "typeface-roboto": "0.0.54",
    "universal-cookie": "^3.1.0"
  },
  "resolutions": {
    "graphql": "^15.4.0",
    "graphql-compose": "^7.25.0",
    "webpack": "^5.24.2"
  },```
@receter
Copy link
Author

receter commented Apr 27, 2021

I did log some variables too:

// Resolve / reject the promise
      if (childCompilation && childCompilation.errors && childCompilation.errors.length) {
        var errorDetails = childCompilation.errors.map(function (error) {
          return error.message + (error.error ? ':\n' + error.error : '');
        }).join('\n');
        reject(new Error('Child compilation failed:\n' + errorDetails));
      } else if (err) {
        reject(err);
      } else {

        console.log(childCompilation.assets);
        console.log(childCompilation.assets[outputName].source());
        console.log(outputName);
        console.log('test');

        resolve({
          outputName: outputName,
          stats: JSON.parse(childCompilation.assets[outputName].source())
        });
      }

Result:

{
  '.iconstats.json': { source: [Function: source], size: [Function: size] }
}
⠀
.iconstats.json
test

@dylan-13
Copy link

dylan-13 commented Apr 28, 2021

You'll have more help if you put this issue on Gatsby repo, and like that you'll trigger a problem that they can relate on the doc.

@Clement-Bresson
Copy link

I got the same issue with gatsby-plugin-favicon + gatsby v3.
If it can help, I ended up using https://www.gatsbyjs.com/plugins/gatsby-plugin-manifest/ which handles favicon (+ other things) and works well with gatsby v3.

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

3 participants