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.

msw init cli throws error "Unexpected token '?'"

See original GitHub issue

Describe the bug

When I execute command npx msw init public/ --save I get the following error: Unexpected token '?'.

Environment

  • msw: 0.35.0
  • nodejs: 12.18.2
  • npm: 6.14.5

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
kettanaitocommented, Sep 15, 2021

Okay, I think I’ve found the root cause.

inquirer@8.1.3 introduced a bug in the rawlist module that resulted in the “Unexpected token ?” exception for any consumer (which MSW CLI is). You can see inquirer@8.1.4 release notes that mention the fix for this issue.

SInce inquirer is installed per semver, users that installed MSW in the window when 8.1.4 was the latest inquirer version got this issue. This issue won’t be reproducible in any new installations, as the issue is fixed in inquirer.

1reaction
kettanaitocommented, Sep 15, 2021

I suggest you re-install MSW. This will propagate the latest inquirer, which is 8.1.5. You can verify that via npm ls inquirer after the installation (you’ll see it under the msw package).

Read more comments on GitHub >

github_iconTop Results From Across the Web

init - Cli - Mock Service Worker Docs
init. Places the Service Worker file into a given public directory of your application. Usage. 1npx msw init <PUBLIC_DIR> [options].
Read more >
Mobile Center CLI, "SyntaxError: Unexpected token" When ...
This error appears because you have an earlier version of Node installed on your machine. The Mobile Center CLI, mobile-center , requires the...
Read more >
How to set up a Front-End project with Vite, React, and ...
Output of running the ESLint init command. The above commands will install ESLint on the project and a configuration file .eslintrc.json as ...
Read more >
codegen.ts file - GraphQL Code Generator
GraphQL Code Generator relies on a configuration file named codegen.ts to manage all possible options, input, and output document types. The CLI ......
Read more >
jest uuid unexpected token - You.com | The Search Engine You ...
JEST - SyntaxError: Unexpected token 'export' with uuid library ... doesn't get rid of the error, and I can't downgrade to Node v12...
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