Docusaurus: Fresh install will not start... Syntax Error

Created on 3 Aug 2020  ·  11Comments  ·  Source: facebook/docusaurus

🐛 Bug Report

Followed steps in the Getting Started section (https://docusaurus.io/docs/en/installation) to install version 1.14.5 of Docusaurus.

node: v12.18.3
npm: 6.14.6
yarn: 1.22.4

To Reproduce

mkdir mysite
cd mysite

npx docusaurus-init
cd website
yarn start

Expected behavior

Expected the server to start so I could begin writing docs for my site.

Actual Behavior

yarn start fails with Syntax Error

$yarn start
yarn run v1.22.4
warning package.json: No license field
$ docusaurus-start
LiveReload server started on port 35729
Failed to start Docusaurus server: SyntaxError: Unexpected token (37:15)
error Command failed with exit code 1.

Your Environment

  • Docusaurus version used: 1.14.5
    node: v12.18.3
    npm: 6.14.6
    yarn: 1.22.4
    macOS 10.14.5
bug needs triage

Most helpful comment

So, it is a bug introduced in this PR: https://github.com/facebook/docusaurus/pull/2331

The issue is on the Users page:
image

The v1 parser is Babylon v6, and v6 does not support React fragments. Replacing the fragment by a div or <React.Fragment> solves it.

I'm not going to upgrade Babylon in v1 but will release a fix soon so that v1 can be initialized without issue. Also will add some useful logs so that this kind of problem is easier to debug.

Will be fixed in https://github.com/facebook/docusaurus/pull/3213

All 11 comments

Hi

Maybe try 1.14.4

As 1.14.5 was my first v1 release I might did something wrong. Will check
tomorrow

Le lun. 3 août 2020 à 20:06, Jeff Hawkins notifications@github.com a
écrit :

🐛 Bug Report

(A clear and concise description of what the bug is)

Followed steps in the Getting Started section (
https://docusaurus.io/docs/en/installation) to install version 1.14.5 of
Docusaurus.

node: v12.18.3
npm: 6.14.6
yarn: 1.22.4
To Reproduce

mkdir mysite
cd mysite

npx docusaurus-init
cd website
yarn start
Expected behavior

Expected the server to start so I could begin writing docs for my site.
Actual Behavior

yarn start fails with Syntax Error

$yarn start
yarn run v1.22.4
warning package.json: No license field
$ docusaurus-start
LiveReload server started on port 35729
Failed to start Docusaurus server: SyntaxError: Unexpected token (37:15)
error Command failed with exit code 1.
Your Environment

  • Docusaurus version used: 1.14.5
    node: v12.18.3
    npm: 6.14.6
    yarn: 1.22.4
    macOS 10.14.5


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/facebook/docusaurus/issues/3199, or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAFW6PXA7PJGRBOOC4YOAJ3R634CHANCNFSM4PTSVCAA
.

Same here

Same here((

Same here.

sorry for that will take a look asap

Something weird I noticed is that on my computer, running npx docusaurus-init init website actually produces a v2 site instead of a v1 site.

But, the v2 site does not work due to a validation error:

image
Maybe this is a bug only I have for some weird reason...

Can you please tell me what's your package.json, and confirm you are on v1? Not only @jeffreyhawkins , but all of you please.

If you are on v1, is the error SyntaxError: Unexpected token ? are there additional info like a stracktrace, screenshot, or something to share?

I can confirm version 1.14.5 is in the package.json.

They only error I see is SyntaxError: Unexpected token (37:15) no other information is shown.

Screen Shot 2020-08-04 at 1 46 21 PM

package.json

{
  "scripts": {
    "examples": "docusaurus-examples",
    "start": "docusaurus-start",
    "build": "docusaurus-build",
    "publish-gh-pages": "docusaurus-publish",
    "write-translations": "docusaurus-write-translations",
    "version": "docusaurus-version",
    "rename-version": "docusaurus-rename-version"
  },
  "devDependencies": {
    "docusaurus": "^1.14.5"
  }
}

the logs:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/home/username/.nvm/versions/node/v12.18.1/bin/node',
1 verbose cli   '/home/username/.nvm/versions/node/v12.18.1/bin/npm',
1 verbose cli   'start'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle @~prestart: @
6 info lifecycle @~start: @
7 verbose lifecycle @~start: unsafe-perm in lifecycle true
8 verbose lifecycle @~start: PATH: /home/username/.nvm/versions/node/v12.18.1/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/username/projects/website/node_modules/.bin:/home/username/.nvm/versions/node/v12.18.1/bin:/home/username/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle @~start: CWD: /home/username/projects/website
10 silly lifecycle @~start: Args: [ '-c', 'docusaurus-start' ]
11 silly lifecycle @~start: Returned: code: 1  signal: null
12 info lifecycle @~start: Failed to exec start script
13 verbose stack Error: @ start: `docusaurus-start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/home/username/.nvm/versions/node/v12.18.1/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (/home/username/.nvm/versions/node/v12.18.1/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid @
15 verbose cwd /home/username/projects/website
16 verbose Linux 5.4.0-42-generic
17 verbose argv "/home/username/.nvm/versions/node/v12.18.1/bin/node" "/home/username/.nvm/versions/node/v12.18.1/bin/npm" "start"
18 verbose node v12.18.1
19 verbose npm  v6.14.5
20 error code ELIFECYCLE
21 error errno 1
22 error @ start: `docusaurus-start`
22 error Exit status 1
23 error Failed at the @ start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

So, it is a bug introduced in this PR: https://github.com/facebook/docusaurus/pull/2331

The issue is on the Users page:
image

The v1 parser is Babylon v6, and v6 does not support React fragments. Replacing the fragment by a div or <React.Fragment> solves it.

I'm not going to upgrade Babylon in v1 but will release a fix soon so that v1 can be initialized without issue. Also will add some useful logs so that this kind of problem is easier to debug.

Will be fixed in https://github.com/facebook/docusaurus/pull/3213

Release 1.14.6, seems to work now

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NikitaIT picture NikitaIT  ·  3Comments

nebrelbug picture nebrelbug  ·  3Comments

lex111 picture lex111  ·  3Comments

JoelMarcey picture JoelMarcey  ·  3Comments

ericnakagawa picture ericnakagawa  ·  3Comments