yaml: Unexpected Token Error

Found in: yaml/dist/compose/composer.js

if (prelude[i + 1]?.[0] !== '#')

Not expecting the period in between the ? and [0].

Threw errors when trying to run in some cases (failed on cron job execution).

Rolled back to v2.0.1 and that seemed to stop the issue from occurring.

Full Stack Trace

yaml/dist/compose/composer.js:33
                if (prelude[i + 1]?.[0] !== '#')
                                   ^

SyntaxError: Unexpected token .
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (node_modules/yaml/dist/index.js:3:16)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 11
  • Comments: 25 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Here’s the fix… reinstall everything. https://nodejs.org/en/download

@MrWook You’re using -r esm as a command-line flag, which should be completely unnecessary with Node.js v16. Internally, that’s using Webpack v4 to transpile files while loading them.