I have a monorepo project created with lerna.
I am trying to create a CI flow to test my repository installation and build actions on a remote environment.
After hitting lerna bootstrap to install all packages dependencies, I am using lerna run build --stream on the root folder which invokes lerna run build for each sub package I have in my repository.
This flow works great on my local machine but fails to work using travis-ci build.
Conclusions so far:
--no-ci, --force-local changes anything.~/sqpoc/node_modules/@superquery/components/dist suggesting that build files are properly created, meaning issue is probably related to internal lerna symlink flow which fails on the stated environments.Output:
$ lerna run build --stream
lerna notice cli v4.0.0
lerna info Executing command in 4 packages: "yarn run build"
@superquery/components: $ node ./scripts/build.ts
@superquery/greeter: $ tsc -p tsconfig.release.json && webpack
@superquery/superquery: $ react-scripts build
@superquery/superquery: Creating an optimized production build...
@superquery/greeter: asset bundle.js 39.4 KiB [compared for emit] (name: main)
@superquery/greeter: runtime modules 670 bytes 3 modules
@superquery/greeter: cacheable modules 11.5 KiB
@superquery/greeter: ./build/src/main.js 701 bytes [built] [code generated]
@superquery/greeter: ./node_modules/tslib/tslib.es6.js 10.8 KiB [built] [code generated]
@superquery/greeter: webpack 5.37.0 compiled successfully in 3703 ms
@superquery/server: $ tsc -p tsconfig.release.json
@superquery/superquery: Failed to compile.
@superquery/superquery: ./src/App.tsx
@superquery/superquery: Cannot find module: '@superquery/components'. Make sure this package is installed.
@superquery/superquery: You can install this package by running: yarn add @superquery/components.
@superquery/superquery: error Command failed with exit code 1.
@superquery/superquery: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
lerna ERR! yarn run build exited 1 in '@superquery/superquery'
error Command failed with exit code 1.
Expected output:
$ lerna run build --stream
lerna notice cli v4.0.0
lerna info Executing command in 4 packages: "yarn run build"
@superquery/components: $ node ./scripts/build.ts
@superquery/greeter: $ tsc -p tsconfig.release.json && webpack
@superquery/greeter: asset bundle.js 39.4 KiB [compared for emit] (name: main)
@superquery/greeter: runtime modules 670 bytes 3 modules
@superquery/greeter: cacheable modules 11.5 KiB
@superquery/greeter: ./build/src/main.js 701 bytes [built] [code generated]
@superquery/greeter: ./node_modules/tslib/tslib.es6.js 10.8 KiB [built] [code generated]
@superquery/greeter: webpack 5.37.0 compiled successfully in 1521 ms
@superquery/server: $ tsc -p tsconfig.release.json
@superquery/superquery: $ react-scripts build
@superquery/superquery: Creating an optimized production build...
@superquery/superquery: Compiled successfully.
@superquery/superquery: File sizes after gzip:
@superquery/superquery: 119.52 KB build/static/js/2.ea8fed9a.chunk.js
@superquery/superquery: 4.79 KB build/static/js/main.7a35accd.chunk.js
@superquery/superquery: 1.41 KB build/static/js/3.80a7969b.chunk.js
@superquery/superquery: 1.17 KB build/static/js/runtime-main.d48b464c.js
@superquery/superquery: 574 B build/static/css/main.9d5b29c0.chunk.css
@superquery/superquery: The project was built assuming it is hosted at /.
@superquery/superquery: You can control this with the homepage field in your package.json.
@superquery/superquery: The build folder is ready to be deployed.
@superquery/superquery: You may serve it with a static server:
@superquery/superquery: npm install -g serve
@superquery/superquery: serve -s build
@superquery/superquery: Find out more about deployment here:
@superquery/superquery: https://cra.link/deployment
lerna success run Ran npm script 'build' in 4 packages in 35.9s:
lerna success - @superquery/components
lerna success - @superquery/greeter
lerna success - @superquery/server
lerna success - @superquery/superquery
✨ Done in 37.28s.
package.json file:
{
"name": "superquery",
"version": "1.0.0",
"author": "***************",
"repository": "https://github.com/doitintl/sqpoc.git",
"main": "index.js",
"license": "MIT",
"private": true,
"workspaces": {
"packages": [
"packages/*"
]
},
"scripts": {
"start": "lerna run start --stream",
"test": "lerna run test --stream",
"test:ci": "lerna run test:ci --stream",
"watch": "lerna run watch --stream",
"storybook": "lerna run storybook --stream",
"production": "lerna run production --stream",
"build": "lerna run build --stream",
"deploy": "lerna run deploy --stream",
"bootstrap": "lerna run rimraf && lerna bootstrap",
"rimraf": "rm -rf node_modules",
"installApp": "yarn rimraf && yarn install && yarn bootstrap",
"dev": "lerna run dev",
"dev-logs": "lerna run dev --parallel",
"dev-module": "lerna run dev --scope",
"e2e": "nightwatch -e chrome,firefox",
"e2e-test": "concurrently -k --success first \"npm run start\" \"npm run e2e\""
},
"devDependencies": {
"chromedriver": "^90.0.0",
"geckodriver": "^1.22.3",
"lerna": "^4.0.0",
"selenium-server": "^3.141.59"
}
}
lerna.json file:
{
"useWorkspaces": true,
"npmClient": "yarn",
"version": "1.0.0",
"packages": [
"packages/superquery",
"packages/components"
]
}
Technology stack used:
node 14.17.0
npm 6.14.13
nvm 0.37.2
lerna 4.0.0
yarn 1.22.10
Tried to follow suggestion from below links (and more), it was either naive or irelevant to my issue.
Lerna bootstrap does not link local dependencies?
https://github.com/lerna/lerna/issues/1444
Solved after updating lerna.json file:
{
"useWorkspaces": true,
"npmClient": "yarn",
"version": "1.0.0"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With