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

Running lerna bootstrap does not install all dependencies #1457

Open
scottmcpherson opened this issue Jun 7, 2018 · 51 comments
Open

Running lerna bootstrap does not install all dependencies #1457

scottmcpherson opened this issue Jun 7, 2018 · 51 comments

Comments

@scottmcpherson
Copy link

@scottmcpherson scottmcpherson commented Jun 7, 2018

Expected Behavior

When running lerna bootstrap all dependencies should be install in packages.

Current Behavior

If I run lerna bootstrap and then run lerna start to start all my clients and packages, I get the following error:

@raisalholdings/raisal-ui:    2263 modules
@raisalholdings/raisal-ui: ERROR in ../raisal-utils/src/reduxUtils.js
@raisalholdings/raisal-ui: Module not found: Error: Can't resolve 'redux-actions' in '/Users/scott/Develop/Raisal/2.0/raisal-clients/packages/raisal-utils/src'
@raisalholdings/raisal-ui: ERROR in ../raisal-utils/src/reduxUtils.js
@raisalholdings/raisal-ui: Module not found: Error: Can't resolve 'redux-optimistic-ui' in '/Users/scott/Develop/Raisal/2.0/raisal-clients/packages/raisal-utils/src'

If I cd into packages/raisal-ui, and run yarn, I get the following error:

error An unexpected error occurred: "ENOENT: no such file or directory, lstat '/Users/scott/Develop/Raisal/2.0/raisal-clients/packages/raisal-ui/node_modules/@raisalholdings/raisal-utils/node_modules/history/node_modules'".
...

But if I run yarn one more time, everything installs in raisal-ui and I can then run lerna run start and everything starts fine.

Possible Solution

Install all deps or provide logs to debug

I have the following setup:

root/
  clients/
  packages/
  lerna.json
  package.json

lerna.json

{
  "lerna": "2.5.1",
  "packages": [
    "clients/*",
    "packages/*"
  ],
  "npmClient": "yarn",
  "version": "2.1.13"
}

Your Environment

Executable Version
lerna --version 2.5.1
npm --version 6.0.0
yarn --version 1.6.0
node --version v8.9.3
OS Version
Sierra 10.13.1
@xpepermint
Copy link

@xpepermint xpepermint commented Jun 23, 2018

This is a serious issue which happens on Node 8, 9 and 10. It's not fixed in lerna@3.0.0-beta.21. Is there a quick workaround?

@scottmcpherson
Copy link
Author

@scottmcpherson scottmcpherson commented Jun 23, 2018

@xpepermint What ended up working for us was creating a custom js bootstrap script and executing that using yarn bootstrap.

The script is scripts/bootstrap.js:

const spawnSync = require('child_process').spawnSync
const fs = require('fs-extra')
const path = require('path')
const chalk = require('chalk')

const RAISAL_UI_DIR = path.join(process.cwd(), 'packages', 'raisal-ui')

if (!fs.existsSync(RAISAL_UI_DIR)) {
  console.log(chalk.red(`Trying to find: ${RAISAL_UI_DIR}`))
  return console.log(
    chalk.red('Yarn bootstrap must be run from root of project')
  )
}
spawnSync('lerna', ['bootstrap'], {
  stdio: 'inherit'
})
spawnSync(/^win/.test(process.platform) ? 'yarn.cmd' : 'yarn', ['install'], {
  cwd: RAISAL_UI_DIR,
  stdio: 'inherit'
})
spawnSync(/^win/.test(process.platform) ? 'yarn.cmd' : 'yarn', ['install'], {
  cwd: RAISAL_UI_DIR,
  stdio: 'inherit'
})

Replace const RAISAL_UI_DIR = path.join(process.cwd(), 'packages', 'raisal-ui') with the dir that needs the packages reinstalled.

And then in my root package.json I added an npm script:

"scripts": {
    "start": "lerna run start --stream --parallel",
    "bootstrap": "node scripts/bootstrap.js",
    ...
@xpepermint
Copy link

@xpepermint xpepermint commented Jun 23, 2018

Thanks @scottmcpherson! I also came to this simple workaround:

// package.json
{
  "scripts": {
    "bootstrap": "lerna exec npm install",
    "publish": "lerna publish --force-publish",
    "test": "lerna run test"
  },
  "devDependencies": {
    "lerna": "3.0.0-beta.21"
  }
}

So the lerna exec npm install command does the trick.

@lucasowens
Copy link

@lucasowens lucasowens commented Jun 26, 2018

I am also having this issue, but I'm having trouble determining exactly which package is the issue.

@scottmcpherson
Copy link
Author

@scottmcpherson scottmcpherson commented Jun 26, 2018

@lucasowens I would suggest posting your terminal output along with your comment. Maybe there's something there that could help?

@lucasowens
Copy link

@lucasowens lucasowens commented Jun 26, 2018

Thanks for the reply @scottmcpherson!

Here is the output when I run lerna bootstrap

λ lerna bootstrap
lerna info version 2.11.0
lerna info versioning independent
lerna info Bootstrapping 19 packages
lerna ERR! execute callback with error
lerna ERR! Error: Command failed: yarn install --mutex network:42424 --non-interactive
lerna ERR! warning "eslint-config-kentcdodds > eslint-import-resolver-babel-module@3.0.0" has unmet peer dependency "babel-core@^6.0.0".
lerna ERR! warning "workspace-aggregator-ee9a09ea-1ce3-403a-a7a8-d1b456360123 > @ournamespace/es-client > request-promise-native@1.0.5" has unmet peer dependency "request@^2.34".
lerna ERR! error An unexpected error occurred: "ENOENT: no such file or directory, lstat 'C:\\Users\\me\\Source\\my-project\\packages\\weartime-domain\\node_modules\\@ournamespace'".
lerna ERR! yarn install v1.7.0
lerna ERR! [1/4] Resolving packages...
lerna ERR! [2/4] Fetching packages...
lerna ERR! info fsevents@1.2.4: The platform "win32" is incompatible with this module.
lerna ERR! info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
lerna ERR! [3/4] Linking dependencies...
lerna ERR! info If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\me\\Source\\my-project\\yarn-error.log".
lerna ERR! info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
lerna ERR!
lerna ERR!     at Promise.all.then.arr (C:\Users\me\AppData\Local\Yarn\Data\global\node_modules\execa\index.js:236:11)
lerna ERR!     at <anonymous>
{ Error: Command failed: yarn install --mutex network:42424 --non-interactive
warning "eslint-config-kentcdodds > eslint-import-resolver-babel-module@3.0.0" has unmet peer dependency "babel-core@^6.0.0".
warning "workspace-aggregator-ee9a09ea-1ce3-403a-a7a8-d1b456360123 > @ournamespace/es-client > request-promise-native@1.0.5" has unmet peer dependency "request@^2.34".
error An unexpected error occurred: "ENOENT: no such file or directory, lstat 'C:\\Users\\me\\Source\\my-project\\packages\\weartime-domain\\node_modules\\@ournamespace'".
yarn install v1.7.0
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.4: The platform "win32" is incompatible with this module.
info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
info If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\me\\Source\\my-project\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

    at Promise.all.then.arr (C:\Users\me\AppData\Local\Yarn\Data\global\node_modules\execa\index.js:236:11)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
  code: 1,
  killed: false,
  stdout: 'yarn install v1.7.0\n[1/4] Resolving packages...\n[2/4] Fetching packages...\ninfo fsevents@1.2.4: The platform "win32" is incompatible with this module.\ninfo "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.\n[3/4] Linking dependencies...\ninfo If you think this is a bug, please open a bug report with the information provided in "C:\\\\Users\\\\me\\\\Source\\\\Repos\\\\GitLab\\\\my-project\\\\yarn-error.log".\ninfo Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.\n',
  stderr: 'warning "eslint-config-kentcdodds > eslint-import-resolver-babel-module@3.0.0" has unmet peer dependency "babel-core@^6.0.0".\nwarning "workspace-aggregator-ee9a09ea-1ce3-403a-a7a8-d1b456360123 > @ournamespace/es-client > request-promise-native@1.0.5" has unmet peer dependency "request@^2.34".\nerror An unexpected error occurred: "ENOENT: no such file or directory, lstat \'C:\\\\Users\\\\me\\\\Source\\\\Repos\\\\GitLab\\\\my-project\\\\packages\\\\weartime-domain\\\\node_modules\\\\@ournamespace\'".\n',
  failed: true,
  signal: null,
  cmd: 'yarn install --mutex network:42424 --non-interactive',
  timedOut: false,
  exitCode: 1 }

The second time I run it, it works as expected.

When I run yarn directly I get:

λ yarn
yarn install v1.7.0
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.4: The platform "win32" is incompatible with this module.
info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "eslint-config-kentcdodds > eslint-import-resolver-babel-module@3.0.0" has unmet peer dependency "babel-core@^6.0.0".
warning "workspace-aggregator-602dc8d5-75c6-4990-b45c-8e79f4bb2e3d > @ournamespace/es-client > request-promise-native@1.0.5" has unmet peer dependency "request@^2.34".
error An unexpected error occurred: "ENOENT: no such file or directory, lstat 'C:\\Users\\me\\Source\\my-project\\packages\\weartime-domain\\node_modules\\@ournamespace'".
info If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\me\\Source\\my-project\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Again it works successfully the second time I run it.

It seems that this is somehow related to winston but I cant be sure, I'm getting inconsistent results.

Any help appreciated!

@evocateur
Copy link
Member

@evocateur evocateur commented Jun 27, 2018

I literally can't debug without an actual reproduction. Telling me what your tree looks like is worthless without the actual contents of the package.json files.

@StrahilKazlachev
Copy link

@StrahilKazlachev StrahilKazlachev commented Jul 3, 2018

My issue seems the same, quite hard to share.
B depends on A.

  • packages
    • A - all is fine
    • B - not fine, A dependencies are not installed

Doing lerna exec -- npm i && lerna link does what I want.
From bootstrap description

  1. npm install all external dependencies of each package.

@evocateur does this mean that the external dependencies of the linked packages will not be installed?
Edit: I'm not hoisting.

@evocateur
Copy link
Member

@evocateur evocateur commented Jul 3, 2018

@StrahilKazlachev
Copy link

@StrahilKazlachev StrahilKazlachev commented Jul 3, 2018

@evocateur Do I understand correctly that when using bootstrap a local sibling external dependencies will stay "under" it(local-pkg-B/node_modules/local-pkg-A/node_modules/ext-dep-1) - loosing the flat structure in local-pkg-B/node_modules I would normally get with npm install?

@evocateur
Copy link
Member

@evocateur evocateur commented Jul 3, 2018

@lucasowens
Copy link

@lucasowens lucasowens commented Jul 6, 2018

I just wanted to mention that this error disappeared for me and I'm not sure why.

@scottmcpherson
Copy link
Author

@scottmcpherson scottmcpherson commented Jul 15, 2018

@evocateur The problem that I ran into while using file specifiers when designing our front-end was that we have multiple core packages that are reused across four clients. They are all in the same mono repo. And the core packages are all started and built with webpack. When we use the file specifiers, we lost live reload, because symlinks were no longer pointing to the original packages. That made file specifiers unusable for our use case.

Have you ran into this issue?

@evocateur
Copy link
Member

@evocateur evocateur commented Jul 15, 2018

@DesignByOnyx
Copy link

@DesignByOnyx DesignByOnyx commented Sep 10, 2018

This problem was fixed for our project by changing our "packages" path to include two asterisks instead of one. I just happened to get lucky on this one:

{
  "packages": [
    "modules/**"
  ],
  "version": "1.0.0"
}

UPDATE: spoke a little too soon I guess, I get different results with successive runs of lerna bootstrap. The first run will install all deps for packages A and B, but not C and D. The second run will install all packages for A and D, but not B and C. It changes on every run. Running lerna link && lerna exec npm install seems to do the trick for now. Still investigating.

@silvenon
Copy link

@silvenon silvenon commented Oct 7, 2018

Repro

I created a Docker container with instructions how to reproduce the issue: silvenon/lerna-bootstrap-issue. You can check out the failing (lerna bootstrap) vs successful (lerna exec yarn && lerna link) script.

@TheAifam5
Copy link

@TheAifam5 TheAifam5 commented Nov 16, 2018

Hey ho,
I have a similar issue but with webpack and yarn workspaces.
I'm using:

  • Node: 11.2.0
  • Webpack: 4.25.1
  • Yarn: 1.12.3
  • lerna: 3.4.3

Workspace config:

  "workspaces": [
    "shared",
    "microservices/*"
  ]

Directory layout:

shared/package.json
microservices/<name>/package.json

Webpack config:

import * as webpack from 'webpack';
import * as path from 'path';
import * as nodeExternals from 'webpack-node-externals';
import tsConfigPathsPlugin from 'tsconfig-paths-webpack-plugin';
import EntryRunnerWebpackPlugin from 'entry-runner-webpack-plugin';

const config: webpack.Configuration = {
  entry: ['webpack/hot/poll?1000', './main.hmr.ts'],
  target: 'node',
  context: path.resolve('./src'),
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'server.js',
  },
  externals: [
    nodeExternals({
      whitelist: ['webpack/hot/poll?1000'],
    }),
  ],
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: 'ts-loader',
        exclude: /node_modules/,
      },
    ],
  },
  mode: 'development',
  resolve: {
    extensions: ['.tsx', '.ts', '.js'],
    plugins: [new tsConfigPathsPlugin()],
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new EntryRunnerWebpackPlugin(path.resolve(__dirname), 'server.js'),
  ],
};

export default config;

Log:

lerna ERR! yarn run build exited 1 in 'microservice-database'
lerna ERR! yarn run build stdout:
$ webpack
Hash: 11947ae751359d9ff957
Version: webpack 4.25.1
Time: 11689ms
Built at: 11/17/2018 12:05:48 AM
    Asset      Size  Chunks             Chunk Names
server.js  8.86 MiB    main  [emitted]  main
Entrypoint main = server.js
[0] multi webpack/hot/poll?1000 ./main.hmr.ts 40 bytes {main} [built]
[../../../node_modules/@nestjs/common/utils sync recursive] /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/@nestjs/common/utils sync 160 bytes {main} [optional] [built]
[../../../node_modules/webpack/hot/log-apply-result.js] (webpack)/hot/log-apply-result.js 1.27 KiB {main} [built]
[../../../node_modules/webpack/hot/log.js] (webpack)/hot/log.js 1.11 KiB {main} [built]
[../../../node_modules/webpack/hot/poll.js?1000] (webpack)/hot/poll.js?1000 1.15 KiB {main} [built]
[./app.module.ts] 933 bytes {main} [built]
[./database/database.module.ts] 1.02 KiB {main} [built]
[./main.hmr.ts] 1.22 KiB {main} [built]
[./main.options.ts] 262 bytes {main} [built]
[./users/users.controller.ts] 2.85 KiB {main} [built]
[./users/users.module.ts] 1.24 KiB {main} [built]
[./users/users.providers.ts] 242 bytes {main} [built]
[./users/users.service.ts] 2.44 KiB {main} [built]
[http] external "http" 42 bytes {main} [built]
[https] external "https" 42 bytes {main} [built]
    + 1477 hidden modules

WARNING in /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/@nestjs/common/utils/load-package.util.js 8:15-35
Critical dependency: the request of a dependency is an expression
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/@nestjs/core/nest-factory.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/@nestjs/core/index.js
 @ ./main.hmr.ts
 @ multi webpack/hot/poll?1000 ./main.hmr.ts

WARNING in /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/optional/optional.js 6:11-26
Critical dependency: the request of a dependency is an expression
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/@nestjs/core/nest-application.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/@nestjs/core/index.js
 @ ./main.hmr.ts
 @ multi webpack/hot/poll?1000 ./main.hmr.ts

WARNING in /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize-typescript/lib/services/models.js 175:29-46
Critical dependency: the request of a dependency is an expression
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize-typescript/lib/models/BaseModel.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize-typescript/lib/models/Model.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize-typescript/index.js
 @ ./users/user.entity.ts
 @ ./users/users.service.ts
 @ ./users/users.module.ts
 @ ./app.module.ts
 @ ./main.hmr.ts
 @ multi webpack/hot/poll?1000 ./main.hmr.ts

WARNING in /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/sequelize.js 393:61-74
Critical dependency: the request of a dependency is an expression
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/index.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize-typescript/lib/enums/DataType.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize-typescript/index.js
 @ ./users/user.entity.ts
 @ ./users/users.service.ts
 @ ./users/users.module.ts
 @ ./app.module.ts
 @ ./main.hmr.ts
 @ multi webpack/hot/poll?1000 ./main.hmr.ts

WARNING in /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/dialects/mssql/connection-manager.js 21:19-62
Critical dependency: the request of a dependency is an expression
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/dialects/mssql/index.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/sequelize.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/index.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize-typescript/lib/enums/DataType.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize-typescript/index.js
 @ ./users/user.entity.ts
 @ ./users/users.service.ts
 @ ./users/users.module.ts
 @ ./app.module.ts
 @ ./main.hmr.ts
 @ multi webpack/hot/poll?1000 ./main.hmr.ts

WARNING in /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/dialects/mysql/connection-manager.js 32:19-62
Critical dependency: the request of a dependency is an expression
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/dialects/mysql/index.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/sequelize.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/index.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize-typescript/lib/enums/DataType.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize-typescript/index.js
 @ ./users/user.entity.ts
 @ ./users/users.service.ts
 @ ./users/users.module.ts
 @ ./app.module.ts
 @ ./main.hmr.ts
 @ multi webpack/hot/poll?1000 ./main.hmr.ts

WARNING in /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/dialects/postgres/connection-manager.js 22:16-59
Critical dependency: the request of a dependency is an expression
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/dialects/postgres/index.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/sequelize.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/index.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize-typescript/lib/enums/DataType.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize-typescript/index.js
 @ ./users/user.entity.ts
 @ ./users/users.service.ts
 @ ./users/users.module.ts
 @ ./app.module.ts
 @ ./main.hmr.ts
 @ multi webpack/hot/poll?1000 ./main.hmr.ts

WARNING in /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/dialects/sqlite/connection-manager.js 25:19-62
Critical dependency: the request of a dependency is an expression
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/dialects/sqlite/index.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/sequelize.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/index.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize-typescript/lib/enums/DataType.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize-typescript/index.js
 @ ./users/user.entity.ts
 @ ./users/users.service.ts
 @ ./users/users.module.ts
 @ ./app.module.ts
 @ ./main.hmr.ts
 @ multi webpack/hot/poll?1000 ./main.hmr.ts

WARNING in /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/express/lib/view.js 81:13-25
Critical dependency: the request of a dependency is an expression
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/express/lib/application.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/express/lib/express.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/express/index.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/@nestjs/core/adapters/express-adapter.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/@nestjs/core/nest-factory.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/@nestjs/core/index.js
 @ ./main.hmr.ts
 @ multi webpack/hot/poll?1000 ./main.hmr.ts

WARNING in /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/mysql2/lib/helpers.js
Module not found: Error: Can't resolve 'cardinal' in '/home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/mysql2/lib'
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/mysql2/lib/helpers.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/mysql2/lib/parsers/binary_parser.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/mysql2/lib/commands/execute.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/mysql2/lib/commands sync ^\.\/.*\.js$
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/mysql2/lib/commands/index.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/mysql2/lib/connection.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/mysql2/index.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/dialects/mysql/connection-manager.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/dialects/mysql/index.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/sequelize.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/index.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize-typescript/lib/enums/DataType.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize-typescript/index.js
 @ ./users/user.entity.ts
 @ ./users/users.service.ts
 @ ./users/users.module.ts
 @ ./app.module.ts
 @ ./main.hmr.ts
 @ multi webpack/hot/poll?1000 ./main.hmr.ts

WARNING in /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/dialects/postgres/connection-manager.js
Module not found: Error: Can't resolve 'pg' in '/home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/dialects/postgres'
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/dialects/postgres/connection-manager.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/dialects/postgres/index.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/lib/sequelize.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize/index.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize-typescript/lib/enums/DataType.js
 @ /home/theaifam5/Documents/Projects/TheAifam5/nestjs-docker-microservices/node_modules/sequelize-typescript/index.js
 @ ./users/user.entity.ts
 @ ./users/users.service.ts
 @ ./users/users.module.ts
 @ ./app.module.ts
 @ ./main.hmr.ts
 @ multi webpack/hot/poll?1000 ./main.hmr.ts
@elie222
Copy link

@elie222 elie222 commented Nov 18, 2018

Same issues for us. Banging my head against a wall. Works fine on my Mac. Causing me issues on remote Ubuntu server or in a docker container.

@silvenon
Copy link

@silvenon silvenon commented Nov 18, 2018

@TheAifam5 @elie222 what is your Lerna configuration (lerna.json)?

@TheAifam5
Copy link

@TheAifam5 TheAifam5 commented Nov 18, 2018

@silvenon

{
  "packages": ["shared/*", "apps/*", "services/*"],
  "npmClient": "yarn",
  "useWorkspaces": true,
  "version": "independent",
  "stream": true,
  "parallel": true
}

I think I should open a new issue, for webpack-only related stuff.

@silvenon
Copy link

@silvenon silvenon commented Nov 18, 2018

Maybe, but it seems like the shared part of your packages field doesn't match workspaces configuration. I think it should be shared rather than shared/*.

@TheAifam5
Copy link

@TheAifam5 TheAifam5 commented Nov 18, 2018

@silvenon shared contains also subfolders with packages which I use everywhere. That's not a problem here. The problem on my side, is about that webpack does not work properly.

but what I seen, webpack transpiles to the "server.js" and is usable, but the error messages about missing dependencies is annoying.

services/webpack.common.ts

import * as webpack from 'webpack';

import * as webpackMerge from 'webpack-merge';
import * as nodeExternals from 'webpack-node-externals';
import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin';

type WebpackMode = 'development' | 'production';

export default (
  configs: webpack.Configuration[],
  _: any,
  argv: { [name: string]: any },
): webpack.Configuration => {
  let mode: WebpackMode = 'development';
  let isHot = false;

  if (process.env.NODE_ENV) {
    mode = process.env.NODE_ENV as WebpackMode;
  } else if ('p' in argv) {
    mode = 'production';
  } else if ('mode' in argv) {
    mode = argv.mode;
  }

  if ('hmr' in argv) {
    isHot = argv.hmr;
  }

  if (mode === 'production' && isHot) {
    throw new Error('Unable to use HMR in production mode!');
  }

  return webpackMerge.smartStrategy({
    'module.rules.use': 'prepend',
  })(
    {
      mode,
      entry: ['webpack/hot/poll?100', `./src/main${isHot ? '.hmr' : ''}.ts`],
      target: 'node',
      output: {
        filename: 'server.js',
        publicPath: '/',
        libraryTarget: 'commonjs',
      },
      module: {
        rules: [
          {
            test: /\.(js|ts)x?$/,
            loader: 'babel-loader',
            options: {
              presets: [
                ['@babel/env', { modules: false }],
                '@babel/typescript',
              ],
              plugins: [
                [
                  '@babel/plugin-proposal-decorators',
                  {
                    decoratorsBeforeExport: true,
                  },
                ],
                '@babel/plugin-proposal-class-properties',
              ],
            },
            include: __dirname,
            exclude: /node_modules/,
          },
        ],
      },
      plugins: [
        new webpack.WatchIgnorePlugin([/\.js$/, /\.d\.ts$/]),
        new webpack.DefinePlugin({
          'process.env.NODE_ENV': JSON.stringify(mode),
        }),
        /*new webpack.NormalModuleReplacementPlugin(
          /\.\.\/migrate/,
          '../util/noop.js',
        ),
        new webpack.NormalModuleReplacementPlugin(
          /\.\.\/seed/,
          '../util/noop.js',
        ),
        new webpack.IgnorePlugin(/mariasql/),
        new webpack.IgnorePlugin(/mssql/),
        new webpack.IgnorePlugin(/mongodb/),
        new webpack.IgnorePlugin(/sql\.js/),
        new webpack.IgnorePlugin(/redis/),
        new webpack.IgnorePlugin(/react-native-sqlite-storage/),
        new webpack.IgnorePlugin(/mysql/),
        new webpack.IgnorePlugin(/mysql2/),
        new webpack.IgnorePlugin(/oracle/),
        new webpack.IgnorePlugin(/oracledb/),
        new webpack.IgnorePlugin(/pg/),
        new webpack.IgnorePlugin(/pg-query-stream/),
        new webpack.IgnorePlugin(/sqlite3/),
        new webpack.IgnorePlugin(/strong-oracle/),
        new webpack.IgnorePlugin(/pg-native/),*/
      ],
      optimization: {
        noEmitOnErrors: true,
        usedExports: !isHot,
        minimize: !isHot,
        removeEmptyChunks: !isHot,
      },
      externals: [nodeExternals()],
      resolve: {
        extensions: ['.ts', '.tsx', '.js', '.json'],
        plugins: [new TsconfigPathsPlugin()],
        modules: ['node_modules'],
        symlinks: false,
      },
      stats: 'verbose',
      /*stats: {
        warningsFilter: /export .* was not found in/,
      },*/
    },
    ...configs,
  );
};

and every subproject in services has:

import * as path from 'path';
import webpack from 'webpack';
import webpackCommon from '../webpack.common';

export default webpackCommon.bind(undefined, [
  {
    context: path.resolve(__dirname),
    output: {
      path: path.join(__dirname, 'dist'),
    },
    resolve: {
      modules: [path.join(__dirname, 'node_modules')],
    },
  },
] as webpack.Configuration[]);
@TheAifam5
Copy link

@TheAifam5 TheAifam5 commented Nov 18, 2018

Nevermind, I found the problem, for my case:

services/webpack.common.ts

externals: [
        nodeExternals(),
        nodeExternals({
          modulesFromFile: true,
        }),
        nodeExternals({
          modulesDir: path.resolve(__dirname, '../node_modules'),
        }),
      ],
@stale
Copy link

@stale stale bot commented Jan 17, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 17, 2019
@stale stale bot closed this Jan 24, 2019
@galhavivi
Copy link

@galhavivi galhavivi commented Jan 15, 2020

@ktalebian
I had the same issue.. what i end up doing is:

npx lerna bootstrap --force-local --hoist --ci -- --production=false

--hoist will install all external dependencies in the root node_modules and then i used root node_modules packages in all my sub packages package.json -> scripts section. For example from one sub package script i did:

"test": "node ../../node_modules/jest/bin/jest.js"
@foxundermoon
Copy link

@foxundermoon foxundermoon commented Jan 22, 2020

same issue for me
after lerna clean && rm -rf node_modules random success
lerna + yarn workspace

@clearloop
Copy link

@clearloop clearloop commented Apr 13, 2020

Should we lerna exec npm i && lerna link or lerna link && lerna exec npm i? Which is more gentle?

(Well, I think lerna link should go first, but it seems most of the answer above it goes last)

@Nabellaleen
Copy link

@Nabellaleen Nabellaleen commented Apr 24, 2020

I found a case where I had a "corrupted" yarn.lock due to a bad merge-conflict resolution :

I had :

react-dom@^16.13.1:
  version "16.13.1"
  resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.13.1.tgz#c1bd37331a0486c078ee54c4740720993b2e0e7f"
  integrity sha512-81PIMmVLnCNLO/fFOQxdQkvEq/+Hfpv24XNJfpyZhTRfO0QcmQIF/PgCa1zCOj2w1hrn12MFLyaJ/G0+Mxtfag==
  dependencies:
    loose-envify "^1.1.0"
    object-assign "^4.1.1"
    prop-types "^15.6.2"
    scheduler "^0.19.1"

react-dom@^16.8.3:
  version "16.12.0"
  resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.12.0.tgz#0da4b714b8d13c2038c9396b54a92baea633fe11"
  integrity sha512-LMxFfAGrcS3kETtQaCkTKjMiifahaMySFDn71fZUNpPHZQEzmk/GiAeIT8JSOrHB23fnuCOMruL2a8NYlw+8Gw==
  dependencies:
    loose-envify "^1.1.0"
    object-assign "^4.1.1"
    prop-types "^15.6.2"
    scheduler "^0.18.0"

instead of

react-dom@^16.13.1, react-dom@^16.8.3:
  version "16.13.1"
  resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.13.1.tgz#c1bd37331a0486c078ee54c4740720993b2e0e7f"
  integrity sha512-81PIMmVLnCNLO/fFOQxdQkvEq/+Hfpv24XNJfpyZhTRfO0QcmQIF/PgCa1zCOj2w1hrn12MFLyaJ/G0+Mxtfag==
  dependencies:
    loose-envify "^1.1.0"
    object-assign "^4.1.1"
    prop-types "^15.6.2"
    scheduler "^0.19.1"

This results in bad behaviours.
I've fixed by deleting the yarn.lock in local and relaunching a lerna bootstrap

wschurman added a commit to expo/entity that referenced this issue Apr 30, 2020
wschurman added a commit to expo/entity that referenced this issue Apr 30, 2020
* Create tests.yml

* Fix lerna link

lerna/lerna#1457
@amitmadd
Copy link

@amitmadd amitmadd commented May 18, 2020

Facing the same issue with latest version of lerna...

14864 silly saveTree -- ssf@0.10.2 14864 silly saveTree -- frac@1.1.2
14865 warn onlinewebapp@1.0.0 No repository field.
14866 verbose stack RangeError: Maximum call stack size exceeded
14866 verbose stack at RegExp.test ()
14866 verbose stack at isDepOptional (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:428:45)
14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:437:9)
14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9)
14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9)
14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9)
14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9)
14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9)
14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9)
14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9)
14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9)
14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9)
14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9)
14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9)
14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9)
14866 verbose stack at failedDependency (C:\Program Files\nodejs\node_modules\npm\lib\install\deps.js:453:9)
14867 verbose cwd D:\BranchWebApp\branchwebapp\packages\onlinewebapp
14868 verbose Windows_NT 10.0.18362
14869 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "--global-style"
14870 verbose node v12.16.3
14871 verbose npm v6.14.4
14872 error Maximum call stack size exceeded
14873 verbose exit [ 1, true ]

@DrMabuse23
Copy link

@DrMabuse23 DrMabuse23 commented Jul 7, 2020

guys i think you are looking for lerna bootstrap --hoist --nohoist="@ionic" nohoist eyery package for example using scss imports
then do lerna link --force-local be carefull with npm install for example running stebcil test install @types/jest which breaks the hoist from lerna so add just @types/jest as a devdependency and so on. in lerna dont use npm install use lerna add --scope ...

@LeandroDoldan
Copy link

@LeandroDoldan LeandroDoldan commented Jul 7, 2020

Using npx lerna bootstrap --force-local was the only thing that worked for me! Could anyone please explain to me what this flag does? This is the explanation: When passed, this flag causes the bootstrap command to always symlink local dependencies regardless of matching version range. but I don't understand if there's any risk using it

@elizad
Copy link

@elizad elizad commented Jul 29, 2020

Any ideea why I started receiving this error ?

lerna ERR! yarn install --mutex network:42424 --non-interactive exited 1 in '@pu/event-listeners'
lerna ERR! yarn install --mutex network:42424 --non-interactive stdout:
lerna ERR! yarn install --mutex network:42424 --non-interactive stderr:
error Package "" refers to a non-existing file '"D:\pu\packages\auth-service"'.

lerna ERR! yarn install --mutex network:42424 --non-interactive exited 1 in '@pu/event-listeners'
lerna WARN complete Waiting for 3 child processes to exit. CTRL-C to exit immediately.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@phetw
Copy link

@phetw phetw commented Jan 6, 2021

Although lerna exec npm install works fine. This problem still exist on lerna@3.22.1

@colemars
Copy link

@colemars colemars commented Jan 21, 2021

Running into this issue all of a sudden as well

@thomaswmanion
Copy link

@thomaswmanion thomaswmanion commented Jan 26, 2021

Still going on :(

@loyalk
Copy link

@loyalk loyalk commented Jan 31, 2021

Still a problem! Any solution yet?

@unclemantis
Copy link

@unclemantis unclemantis commented Feb 10, 2021

experiencing this issue too.
yarn install --mutex network:42424 --non-interactive exited 1 in 'stacks.js'

while running lerna bootstrap. Very frustrating for a newcomer.

@phetw
Copy link

@phetw phetw commented Feb 11, 2021

IMO It's best to let yarn workspace, npm workspace or pnpm to handle dependencies and hoisting.

@somq
Copy link

@somq somq commented Mar 26, 2021

Same here with lerna 4.0.0

@marschhuynh
Copy link

@marschhuynh marschhuynh commented Apr 2, 2021

In case you want devDependencies to be installed, you have to make sure that NODE_ENV is not "production"

@veeramarni
Copy link

@veeramarni veeramarni commented Apr 3, 2021

@marschhuynh I set to below, but still devDependencies from packages are not getting installed.

    "lerna": "cross-env NODE_ENV=development lerna bootstrap",

@TomaszG
Copy link

@TomaszG TomaszG commented Apr 16, 2021

I had the same issue and the root cause was that some packages were not listed in the root package.json file (probably because they were not added using npx lerna add but manually). All packages in a monorepo should be listed in root package.json file:

// root package.json
{
  (...)
  "dependencies": {
    "@repo/package-name": "file:packages/package-name",
    (...)
  }
}
@GiancarlosIO
Copy link

@GiancarlosIO GiancarlosIO commented Apr 28, 2021

so.. is there any solution for this problema? 😢

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

Successfully merging a pull request may close this issue.

None yet