question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

webpack/webpack-dev-server 2 throws `ERROR in json.js - Parenthesized pattern`

See original GitHub issue

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

Report an error. But it could be user error. 😃

What is the current behavior?

When running webpack-dev-server I get the error:

ERROR in ./~/json3/lib/json3.js
Module parse failed: /node_modules/json3/lib/json3.js Parenthesized pattern (89:12)
You may need an appropriate loader to handle this file type.
|           if (stringifySupported) {
|             // A test function object with a custom `toJSON` method.
|             (value = function () {
|               return 1;
|             }).toJSON = value;
 @ ./~/sockjs-client/lib/main.js 7:12-28
 @ ./~/sockjs-client/lib/entry.js
 @ (webpack)-dev-server/client/socket.js
 @ (webpack)-dev-server/client?http://localhost:8080
 @ multi (webpack)-dev-server/client?http://localhost:8080 ./main.tsx

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

My configuration for a React + TypeScript project:

module.exports = {
    context: __dirname + "/src",
    entry: "./main.tsx",
    output: {
        path: __dirname + "/dist",
        filename: "bundle.js"
    },
    devServer: {
     contentBase: __dirname + "/src",
    },
    devtool: "source-map",
    resolve: {
        extensions: [".tsx", ".ts", ".js"]
    },
    module: {
        loaders: [
            {
                test: /\.tsx?$/,
                loader: "ts-loader",
                exclude: /node_modules/
            }
        ]
    }
}

This config works without problems using webpack-dev-server@1 (the only config difference being "" added to extensions: ["", ".tsx", ".ts", ".js"] ).

I am not using json3 directly in code anywhere.

What is the expected behavior?

No error.

Please mention your webpack and Operating System version.

  • webpack/webpack-dev-server 2.2.1
  • OSX 10.11.4

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
yakovkhalinskycommented, Feb 3, 2017

I can confirm that installing acorn 4.0.7 manually fixes the issue

0reactions
aaronbeallcommented, Feb 3, 2017

It seems to have been the acorn issue… I blew away node_modules and re-installed webpack@2 webpack-dev-server@2 and the problem no longer exists, when I look at the acorn package it is using 4.0.8 which apparently fixed the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolving "Parsing error: Parenthesized pattern" in pure js
I'm working on a simple assignment for a job training with html and js. There is an online code ...
Read more >
SyntaxError: JSON.parse: bad parsing Breaking Your Code ...
parse() method, the method expects properly formatted JSON as the first argument. When it detects invalid JSON, it throws a JSON Parse error....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found