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

Version 6.0: Unexpected token '.' #3368

Closed
dep opened this issue Oct 13, 2022 · 17 comments
Closed

Version 6.0: Unexpected token '.' #3368

dep opened this issue Oct 13, 2022 · 17 comments

Comments

@dep
Copy link

dep commented Oct 13, 2022

Current Behavior

npx lerna bootstrap --scope=@box/foo-bar --include-dependencies --concurrency 2

Crashes with the following error:

Unexpected token '.'

Any other lerna command also fails (npx lerna info, lerna repair, etc).

Expected Behavior

Bootstraps the application.

Steps to Reproduce

Install Lerna 6.0.0, npm install

Run

npx lerna bootstrap --scope=@box/foo-bar --include-dependencies --concurrency 2

Failure Logs / Configuration

{
  "packages": ["applications/**", "components/**", "config/**", "scripts/**"],
  "version": "independent",
  "command": {
    "bootstrap": {
      "hoist": true,
      "strict": true,
      "nohoist": [
        "@box/shared-dev-dependencies-foo",
        "babel-jest",
        "css-loader",
        "jest",
        "jest-environment-jsdom",
        "karma",
        "karma-webpack",
        "source-map-loader",
        "style-loader",
        "webpack",
        "webpack-cli"
      ]
    },
    "publish": {
      "conventionalCommits": true,
      "exact": true,
      "message": "[skip ci] chore: release",
      "yes": true,
      "ignoreChanges": [
        "**/CHANGELOG.md",
        "**/node_modules/**",
        "**/package.json",
        "**/*.md",
        "**/.depcheckrc"
      ]
    }
  }
}

Lerna log is empty.

Environment

 Environment info:

  System:
    OS: macOS 12.6
    CPU: (10) x64 Apple M1 Pro
  Binaries:
    Node: 12.22.7 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 6.14.15 - /usr/local/bin/npm
  Utilities:
    Git: 2.32.1 - /usr/bin/git
  npmPackages:
    lerna: 6.0.0 => 6.0.0

Downgrading to 5.5.4 immediately fixes this issue.

@dep dep added the type: bug label Oct 13, 2022
@JamesHenry
Copy link
Member

Hi @dep sorry that you've run into an issue.

I'm a bit confused when you say any other command also fails (including lerna info), but then you've successfully provided the output of lerna info in your issue description.

Could you please clarify what commands fail and whether or not the error message is always the same?

@dep
Copy link
Author

dep commented Oct 13, 2022

I had to roll back in order to get the lerna info output (then added the 6.0.0 stuff manually). In general today our stack is ridden with this mysterious error:

Unexpected token '.'

Even after rolling back lerna versions. Still digging

@dep
Copy link
Author

dep commented Oct 13, 2022

This is just very strange because we maintain a monorepo where each build kicks off the same action within different applications. In the following screenshots, you can see two feature branch pull requests. Neither of them modify the application code, so these actions are ostensibly running against mainline code. One app is failing in one branch, but passing in other, and vice versa. Here's an example:

Feature 1

CleanShot 2022-10-13 at 14 36 57

CleanShot 2022-10-13 at 14 37 19

Feature 2

CleanShot 2022-10-13 at 14 37 06

CleanShot 2022-10-13 at 14 37 31


I'm just absolutely perplexed.

@dep
Copy link
Author

dep commented Oct 13, 2022

Why would some of these jobs pass while others fail? They all run the same bootstrap command. 😱

@dep
Copy link
Author

dep commented Oct 13, 2022

Bit of an update, and this is weird, but it seems forcing an npm install into the Github actions before running npx lerna bootstrap --scope=@invoca/titan-signals --include-dependencies --concurrency 2 has seemed to alleviate this, though I have no idea why, as we've not needed it before.

@fahslaj
Copy link
Contributor

fahslaj commented Oct 14, 2022

Hi @dep , thank your for reporting the issue. I was able to reproduce the issue described. I believe it is related to your node version of 12.22.7. After upgrading to node 14+, the issue disappeared for me.

Lerna officially supports Node versions 14 or 16+. Please consider upgrading to one of these and trying again.

@BurtHarris
Copy link

I have had this happen as well.

/home/runner/work/mrm/mrm/node_modules/@lerna/package-graph/index.js:7[9](https://github.com/sapegin/mrm/actions/runs/3257863940/jobs/5349474010#step:6:10)
            if (depNode?.version) {
                        ^

For me, the problem is not occurring on Node 10 or 14, just Node 12. Perhaps a V8 issue?

@JamesHenry
Copy link
Member

@BurtHarris node 12 has not been supported since v5 of lerna, and it’s also end of life in general. Please use a supported version of node

@JamesHenry
Copy link
Member

Hi Folks, I'm going to go ahead and close this given that it seems to have been fully explained by using an unsupported version of node. Many thanks!

@JamesHenry JamesHenry closed this as not planned Won't fix, can't repro, duplicate, stale Oct 22, 2022
@dep
Copy link
Author

dep commented Oct 31, 2022

@fahslaj I saw this today after upgrading to Node 16. It seems to be coming from the nx lib someplace. Here's showing me resolving it:

package.json:

{
  "name": "titan",
  "private": true,
  "version": "0.0.0",
  "description": "Invoca's Titan mono repo",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/invoca/Titan.git"
  },
  "bugs": {
    "url": "https://github.com/invoca/Titan/issues"
  },
  "homepage": "https://github.com/invoca/Titan#readme",
  "devDependencies": {
    "lerna": "6.0.1",
    "nx": "15.0.4"
  },
  "engines": {
    "node": "^16.16.0"
  }
}

Outputs:

dpeck: main
$ npx lerna bootstrap
Unexpected token '.'

dpeck: main
$ rm -rf node_modules/nx/

dpeck: main
$ npm install

added 10 packages, removed 2959 packages, changed 5 packages, and audited 702 packages in 20s

61 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

dpeck: main
$ npx lerna bootstrap
lerna notice cli v6.0.1
lerna info versioning independent
lerna info Bootstrapping 21 packages

@dep
Copy link
Author

dep commented Nov 3, 2022

@JamesHenry Can you please re-open this ticket to investigate further? I have multiple users experiencing the same issue in Node 16.16.0.

npx lerna bootstrap --scope=@invoca/titan-core --include-dependencies --concurrency 2 -- --legacy-peer-deps
Unexpected token '.'
make[1]: *** [titan-core] Error 1
child process exited with code 2

it's fixed by the following:

rm -rf node_modules/nx
npm install

Info:

 Environment info:

  System:
    OS: macOS 12.6
    CPU: (10) arm64 Apple M1 Pro
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v16.16.0/bin/npm
  Utilities:
    Git: 2.32.1 - /usr/bin/git
  npmPackages:
    lerna: 6.0.1 => 6.0.1

Something's up though.

@JamesHenry
Copy link
Member

JamesHenry commented Nov 6, 2022

Hi @dep, I'm afraid this does seem to be something very specific with your setup. If the token were fundamentally failing to be parsed on our stated supported node versions (regardless or whether Lerna or Nx related), we would be inundated with commenters/issues.

Perhaps .nvm is not actually being used to resolve node when you are running your failing command? And you are therefore falling back to some system installation which is node 12 or older, for example?

I believe you are the only one who is in a position to investigate further, as noone else has access to your specific setup. If you are able to create a fresh reproduction repo then we will of course help troubleshoot. Feel free to open a new issue in that case.

As an aside, I would strongly encourage you to move away from using lerna bootstrap at this point. The previous maintainer was encouraging folks to do that for years before we took over stewardship of the project, and we have just officially confirmed that we agree with that stance. Please see full context on our Lerna 7 Roadmap here: #3410

@dep
Copy link
Author

dep commented Nov 7, 2022

Apologies, we had some lingering users on Node 12. confirmed after updating to Node 16 that their problems disappeared. Sorry for the false alarm @JamesHenry

@JamesHenry
Copy link
Member

Happy to hear that @dep, thanks!

@dep
Copy link
Author

dep commented Nov 7, 2022

@JamesHenry I'm happy to move away from lerna bootstrap. What's the preferred alternative approach?

@JamesHenry
Copy link
Member

@dep please check out the notes on #3410 but in general the point is that whichever your package manager of choice is, it already supports the ability to link local packages together via their support of "workspaces".

E.g. for npm the docs are here: https://docs.npmjs.com/cli/v8/using-npm/workspaces

As we work through towards Lerna v7 we will produce content on our own site to offer more prescriptive guidance around specific lerna boostrap usage and how it can be adapted for each package manager

@dep
Copy link
Author

dep commented Nov 7, 2022

@JamesHenry Nice! Thank you 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants