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

SyntaxError: Unexpected token '??=' , Lerna Installation Failed #3854

Closed
shashidhar087 opened this issue Oct 2, 2023 · 13 comments
Closed

SyntaxError: Unexpected token '??=' , Lerna Installation Failed #3854

shashidhar087 opened this issue Oct 2, 2023 · 13 comments

Comments

@shashidhar087
Copy link

Current Behavior

SyntaxError: Unexpected token '??='
Lerna Installation Failed

Expected Behavior

Successful install of Lerna

Steps to Reproduce

sudo yarn global add lerna

Failure Logs / Configuration

node version: v14.21.3

Error logs:

yarn global v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[1/2] ⠄ @parcel/watcher
error /usr/local/share/.config/yarn/global/node_modules/nx: Command failed.
Exit code: 1
Command: node ./bin/post-install
Arguments:
Directory: /usr/local/share/.config/yarn/global/node_modules/nx
Output:
/usr/local/share/.config/yarn/global/node_modules/nx/src/project-graph/utils/normalize-project-nodes.js:77
targets[target].configurations ??= {};
^^^

SyntaxError: Unexpected token '??='
at wrapSafe (internal/modules/cjs/loader.js:1029:16)
at Module._compile (internal/modules/cjs/loader.js:1078:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
at Module.load (internal/modules/cjs/loader.js:979:32)
at Function.Module._load (internal/modules/cjs/loader.js:819:12)
at Module.require (internal/modules/cjs/loader.js:1003:19)
at require (internal/modules/cjs/helpers.js:107:18)
at Object. (/usr/local/share/.config/yarn/global/node_modules/nx/src/project-graph/build-project-graph.js:10:35)
at Module._compile (internal/modules/cjs/loader.js:1114:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)

lerna.json

<!-- Please paste your `lerna.json` here -->

lerna-debug.log

<!-- If you have a `lerna-debug.log` available, please paste it here -->
<!-- Otherwise, feel free to delete this <details> block -->

Environment

@aryamohanan
Copy link

I'm having the same problem installing Lerna with node, version 14.21.3

@amorscher
Copy link
Contributor

amorscher commented Oct 5, 2023

Hmm it seems that nx which lerna has a dependency on does no longer support node 14 versions see https://nx.dev/nx-api/workspace/documents/nx-nodejs-typescript-version-matrix . I think this could be the issue.

Is the issue still there with node 16?

@shashidhar087
Copy link
Author

@amorscher Yes issue persists in higher node version too.

We have node version 17.x and error log is,

root@ip-x-x-x-x:~# sudo yarn global add lerna
yarn global v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
error cmd-shim@6.0.1: The engine "node" is incompatible with this module. Expected version "^14.17.0 || ^16.13.0 || >=18.0.0". Got "17.9.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.

@shashidhar087
Copy link
Author

shashidhar087 commented Oct 5, 2023

sudo yarn global add lerna --ignore-engines 

worked !!

yarn global v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "lerna@7.3.0" with binaries:
      - lerna
Done in 47.96s.

@amorscher
Copy link
Contributor

amorscher commented Oct 5, 2023

Why do you use a 17 version?

Could you go to either 16, 18 or 20? I think these versions are supported. Best is the current lts.

I think we should adapt the node.engine constraint in the packacke.json.

@fahslaj Maybe some of the core team can confirm?

@shashidhar087
Copy link
Author

@kirrg001
Copy link

I am having the same issue.

Node v14.21.3
Lerna v7.3.0

npm ERR! /home/circleci/repo/node_modules/nx/src/project-graph/utils/normalize-project-nodes.js:77
npm ERR! targets[target].configurations ??= {};

Lerna 7.3.0 officially supports Node v14.

I think you need to revert 0bbd74d and release that in a next major version otherwise this is a breaking change.

@kirrg001 kirrg001 mentioned this issue Oct 10, 2023
25 tasks
@JamesHenry
Copy link
Member

JamesHenry commented Oct 10, 2023

@kirrg001 and others - We're sorry for this oversight in our package.json files, but lerna v7 does not support v14.

The important reason why is that Node does not even support Node v14.

In fact node v14 was end of life software (on 30th April 2023) 2 months before lerna v7 was first created. This means that it does not receive any updates or maintenance whatsoever, even if critical security vulnerabilities have been uncovered.

I strongly encourage all folks here to keep up with the maintenance LTS version of Node at an absolute minimum.

Currently the LTS version is v18 (v16 is already fully EOL too):

https://github.com/nodejs/release#release-schedule

We will fix our package.json files in a patch release shortly, and update the v7 release notes, and apologies again for letting this slip through the cracks. Again, though, you should be endeavouring to update your node version based on Node's own releases, not those of your tools such as lerna.

@kirrg001
Copy link

kirrg001 commented Oct 10, 2023

When did you officially drop Node v14 support? 🤔

Could you please share how to use Lerna with Node v14? Which Lerna version can be used? Should be compatible with npm workspaces.

We are running multiple versions in our build + development and I assume others do too. Lot's of products and packages still support Node v14. And this is not about dropping Node v14, it's about the communication.

https://github.com/lerna/lerna/releases?page=2 😕

@JamesHenry
Copy link
Member

@kirrg001 I can't really summarize it any differently than my previous message. It was human error that we did not include a commit in v7 that removed v14 from the engines, and that would have then correspondingly shown up in the release notes. We are sorry for this, we know it was not communicated as we would have wanted.

We have now merged #3861 which corrects this, and it is included in 7.3.1 which I just released. I have also updated the v7 release notes accordingly.

You should be able to use lerna v6 with node 14. I would, however, again recommend that you do not continue to use/maintain tools for EOL node versions.

Sorry again for the confusion here folks!

@kirrg001
Copy link

@JamesHenry You suggested to use Lerna v6 with Node v14
Running into #3609

@JamesHenry
Copy link
Member

@kirrg001 and you've verified that you have nx@15.8.9 in your node_modules per the resolution of that issue?

E.g. npm ls nx will tell you

@kirrg001
Copy link

kirrg001 commented Nov 3, 2023

nx@15.8.9

It's working with using overrides 👍 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

5 participants