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

lerna ERR! TypeError: Cannot read properties of undefined (reading 'ejs') - lerna version #3546

Closed
grabowsd opened this issue Feb 14, 2023 · 3 comments
Assignees

Comments

@grabowsd
Copy link

grabowsd commented Feb 14, 2023

Current Behavior

When running npx lerna version patch --no-git-tag-version --no-push --exact --yes we get the following error:

Screenshot 2023-02-14 at 11 49 59

The issue was introduced in v5.5.0. I believe in this PR: #3308

lerna fails in the lines highlighted below:

Screenshot 2023-02-14 at 12 10 53

I tried to include as much details as possible but please let me know if you need more info.

Expected Behavior

lerna version works for us as expected with v5.4.3.

Screenshot 2023-02-14 at 13 11 56

Steps to Reproduce

run npx lerna version patch --no-git-tag-version --no-push --exact --yes

Failure Logs / Configuration

lerna.json

{
  "lerna": "6.5.1",
  "version": "6.0.1",
  "packages": ["packages/*"],
  "command": {
    "bootstrap": {
      "nohoist": ["@govhhs/govhhs-design-system-core"]
    },
    "publish": {
      "message": "chore(*): publish %s [skip ci]"
    }
  },
  "useNx": false
}

lerna-debug.log

0 silly argv {
0 silly argv   _: [ 'version' ],
0 silly argv   'git-tag-version': false,
0 silly argv   gitTagVersion: false,
0 silly argv   push: false,
0 silly argv   exact: true,
0 silly argv   yes: true,
0 silly argv   y: true,
0 silly argv   lernaVersion: '6.5.1',
0 silly argv   '$0': '/Users/user/DevEnv/SPM-WebApps-test2/node_modules/.bin/lerna',
0 silly argv   bump: 'patch'
0 silly argv }
1 notice cli v6.5.1
2 verbose rootPath /Users/user/DevEnv/SPM-WebApps-test2
3 info current version 6.0.1
4 notice FYI git repository validation has been skipped, please ensure your version bumps are correct
5 silly hasTags
6 verbose hasTags true
7 silly git-describe.sync "4949373c0-dirty" => {"refCount":"11576","sha":"4949373c0","isDirty":true}
8 info Assuming all packages changed
9 verbose updated @spmtest/a11y-helpers
10 verbose updated @spmtest/babel-preset
11 verbose updated @spm/core-ui-locales
12 verbose updated @spm/core-ui
13 verbose updated @spm/core
14 verbose updated @spm/eslint-config
15 verbose updated @spm/intelligent-evidence-gathering-locales
16 verbose updated @spmtest/intelligent-evidence-gathering-test-app
17 verbose updated @spm/intelligent-evidence-gathering
18 verbose updated @spm/mock-server
19 verbose updated @spm/test-framework
20 verbose updated @spmtest/universal-access-config-pack
21 verbose updated @spmtest/universal-access-e2e
22 verbose updated @spm/universal-access-mocks
23 verbose updated @spmtest/universal-access-nfr-testing
24 verbose updated @spm/universal-access-starter-pack
25 verbose updated @spmtest/universal-access-test-mocks
26 verbose updated @spm/universal-access-ui-locales
27 verbose updated @spm/universal-access-ui
28 verbose updated @spm/universal-access
29 verbose updated @spm/web-dev-accelerator-scripts
30 verbose updated @spm/web-dev-accelerator
31 verbose updated @spmtest/wicked-notices
32 warn version Skipping working tree validation, proceed at your own risk
33 info auto-confirmed
34 info execute Skipping git tag/commit
35 info execute Skipping git push
36 info execute Skipping releases
37 silly lifecycle No script for "preversion" in "ua-packages", continuing
38 silly lifecycle No script for "preversion" in "@spmtest/a11y-helpers", continuing
39 silly lifecycle No script for "preversion" in "@spmtest/babel-preset", continuing
40 silly lifecycle No script for "preversion" in "@spm/core-ui-locales", continuing
41 silly lifecycle No script for "preversion" in "@spm/eslint-config", continuing
42 silly lifecycle No script for "preversion" in "@spm/intelligent-evidence-gathering-locales", continuing
43 silly lifecycle No script for "preversion" in "@spm/mock-server", continuing
44 silly lifecycle No script for "preversion" in "@spm/test-framework", continuing
45 silly lifecycle No script for "preversion" in "@spm/universal-access-mocks", continuing
46 silly lifecycle No script for "preversion" in "@spmtest/universal-access-test-mocks", continuing
47 silly lifecycle No script for "preversion" in "@spm/universal-access-ui-locales", continuing
48 verbose version @spm/intelligent-evidence-gathering-locales has no lockfile. Skipping lockfile update.
49 verbose version @spm/core-ui-locales has no lockfile. Skipping lockfile update.
50 verbose version @spm/mock-server has no lockfile. Skipping lockfile update.
51 verbose version @spm/universal-access-mocks has no lockfile. Skipping lockfile update.
52 verbose version @spmtest/universal-access-test-mocks has no lockfile. Skipping lockfile update.
53 verbose version @spm/universal-access-ui-locales has no lockfile. Skipping lockfile update.
54 silly lifecycle No script for "version" in "@spmtest/a11y-helpers", continuing
55 silly lifecycle No script for "preversion" in "@spmtest/wicked-notices", continuing
56 silly lifecycle No script for "version" in "@spm/mock-server", continuing
57 silly lifecycle No script for "version" in "@spm/test-framework", continuing
58 silly lifecycle No script for "preversion" in "@spmtest/universal-access-nfr-testing", continuing
59 silly lifecycle No script for "preversion" in "@spm/web-dev-accelerator", continuing
60 silly lifecycle No script for "version" in "@spm/universal-access-mocks", continuing
61 silly lifecycle No script for "version" in "@spmtest/universal-access-test-mocks", continuing
62 silly lifecycle No script for "preversion" in "@spm/core", continuing
63 silly lifecycle No script for "version" in "@spm/core-ui-locales", continuing
64 silly lifecycle No script for "version" in "@spmtest/babel-preset", continuing
65 silly lifecycle No script for "version" in "@spm/intelligent-evidence-gathering-locales", continuing
66 silly lifecycle No script for "version" in "@spm/eslint-config", continuing
67 silly lifecycle No script for "preversion" in "@spm/web-dev-accelerator-scripts", continuing
68 silly lifecycle No script for "version" in "@spm/universal-access-ui-locales", continuing
69 silly lifecycle No script for "version" in "@spmtest/wicked-notices", continuing
70 silly lifecycle No script for "version" in "@spmtest/universal-access-nfr-testing", continuing
71 silly lifecycle No script for "version" in "@spm/core", continuing
72 silly lifecycle No script for "preversion" in "@spm/core-ui", continuing
73 silly lifecycle No script for "preversion" in "@spmtest/universal-access-e2e", continuing
74 silly lifecycle No script for "version" in "@spm/web-dev-accelerator", continuing
75 silly lifecycle No script for "version" in "@spm/web-dev-accelerator-scripts", continuing
76 error TypeError: Cannot read properties of undefined (reading 'ejs')
76 error     at /Users/user/DevEnv/SPM-WebApps-test2/node_modules/lerna/dist/cli.js:6816:69
76 error     at Array.reduce (<anonymous>)
76 error     at /Users/user/DevEnv/SPM-WebApps-test2/node_modules/lerna/dist/cli.js:6815:89
76 error     at async Promise.all (index 0)
76 error     at async /Users/user/DevEnv/SPM-WebApps-test2/node_modules/p-pipe/index.js:12:19

Environment

Environment info:

System:
OS: macOS 13.0.1
CPU: (10) x64 Apple M1 Pro
Binaries:
Node: 16.18.1 - ~/.nvm/versions/node/v16.18.1/bin/node
npm: 8.19.2 - ~/.nvm/versions/node/v16.18.1/bin/npm
Utilities:
Git: 2.37.1 - /usr/bin/git
npmPackages:
lerna: 6.5.1 => 6.5.1

@fahslaj
Copy link
Contributor

fahslaj commented Feb 16, 2023

Hi @grabowsd , thank you for reporting this issue. This appears to be happening because the package-lock file being updated states that there are dependencies of the updated package, but Lerna isn't seeing a dependencies property within that package's package.json file.

I am working on a fix that will allow Lerna to gracefully handle this case and update the lockfile anyway. In the meantime, the issue should go away by itself if you ensure that the lockfile for each of your packages is up to date (by running npm install within the package directory).

@JamesHenry
Copy link
Member

Thanks again for providing the up to date information, @fahslaj has addressed this in #3546

As he notes, you should be able to resolve this immediately by updating your lockfile before running commands, but lerna will gracefully handle this mismatch in the next version thanks to his PR as well

@grabowsd
Copy link
Author

That's great! Thank you @fahslaj and @JamesHenry.

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

3 participants