Aws-cdk: Tools assume `lerna` is installed globally

Created on 12 Dec 2018  路  5Comments  路  Source: aws/aws-cdk

Developers who don't have lerna installed globally (i.e., via npm install --global lerna) are going to encounter errors with the build scripts:

exec: lerna: not found

One should be able to wrap most lerna invocations in scripts such as buildup and builddown with npx in order to resolve at least that issue, but overall, the directions in CONTRIBUTING should be reviewed to ensure the steps all work without any globally-installed npm packages.

good first issue

Most helpful comment

I guess the larger issue is around being able to use the versions of lerna and other tools from the npm dependencies as specified in the project package.json. It would be safe to use npx lerna and safer to replace occurrences of export PATH=node_modules/.bin:$PATH with export PATH=$(npm bin):$PATH (or add where not present) and then use the lerna (and others) as is since these binaries would be available in the path.

All 5 comments

Can yoi give examples of locations where lerna is invoked globally?

I guess the larger issue is around being able to use the versions of lerna and other tools from the npm dependencies as specified in the project package.json. It would be safe to use npx lerna and safer to replace occurrences of export PATH=node_modules/.bin:$PATH with export PATH=$(npm bin):$PATH (or add where not present) and then use the lerna (and others) as is since these binaries would be available in the path.

Am not sure this fixes the problem. Running the ./install.sh script no longer depends on having lerna installed globally but when running ../../../scripts/buildup in the package dir it complains that lerna: not found.

Taking a look at the node_modules/.bin dir at the project root level I see the lerna symlink exists whereas in the package dir the subfolder node_modules/.bin does not contain the lerna symlink.

Fix 1338 only adds the node_modules/.bin to PATH but if lerna is not installed then it will still not work. Perhaps the buildup script needs to also add ../../../node_modules/.bin to the PATH as it is the only place where lerna is installed

I ran into the same issue that @mattmcclean mentioned. For now I had to run the following before invoking buildup:

$ ./install.sh
$ export PATH=$(npm bin):$PATH # put project-global lerna on the PATH
$ cd packages/@aws-cdk/aws-ecs
$ ../../../scripts/buildup

@rix0rrr Should I submit a PR to the contribution doc or you guys plan on fixing it in some other ways?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pepastach picture pepastach  路  3Comments

PaulMaddox picture PaulMaddox  路  3Comments

nzspambot picture nzspambot  路  3Comments

v-do picture v-do  路  3Comments

ababra picture ababra  路  3Comments