question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Base directory incorrect for monorepos

See original GitHub issue

It looks like the build.command is running in the root directory versus the build.base directory.

https://app.netlify.com/sites/monorepo-base-dir-repro/deploys/5e1f844ba0553600078e5594

This repro repo was reported by a user trying build plugins. He was only able to get them working without a mono repo setup.

https://github.com/DavidWells/netlify-build-mono-repo-base-dir

It seems like we need to detect if build.base exists and then use that as cwd when executing any commands (e.g. build.command: npm run x, utils.run(β€˜thing’), or build.lifecycle.xyz: npm run foo)


Inside the website dir we have an npm script β€œnetlify” https://github.com/DavidWells/netlify-build-mono-repo-base-dir/blob/9c366e1766f86eeb5133b494e3c5a33bdb1bee4d/website/package.json#L18

This is not found. Build logs:

1:30:26 PM: 
1:30:26 PM: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
1:30:26 PM: β”‚ 3. Running build.lifecycle.onBuild command from netlify.toml config file β”‚
1:30:26 PM: β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
1:30:26 PM: 
1:30:26 PM: Running command "npm run netlify"
1:30:27 PM: npm ERR! missing script: netlify
1:30:27 PM: npm ERR! A complete log of this run can be found in:
1:30:27 PM: npm ERR!     /opt/buildhome/.npm/_logs/2020-01-15T21_30_27_020Z-debug.log
1:30:27 PM: 
1:30:27 PM: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
1:30:27 PM: β”‚     Netlify Build Error     β”‚
1:30:27 PM: β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
1:30:27 PM: In "onBuild" command "npm run netlify":
1:30:27 PM: Command failed with exit code 1: npm run netlify

Let me know if you need additional context πŸ˜ƒ

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Benaiahcommented, Feb 11, 2020

I’m still digging into this - I’m not sure how or where the directory is being changed between https://github.com/netlify/buildbot/blob/master/script/run-build.sh#L26, where the current directory is correct, and https://github.com/netlify/buildbot/blob/master/script/run-build.sh#L81, where it isn’t. I’ll update here and at https://github.com/netlify/buildbot/issues/569 when I’ve tracked this down.

0reactions
ehmickycommented, Mar 26, 2020

This is fixed now! πŸŽ‰

Read more comments on GitHub >

github_iconTop Results From Across the Web

Granular access to directories within monorepo - git
Yes, and one can achieve such complete separation with a monorepo and subtrees. "The fact that code is then referenced in your own...
Read more >
Monorepos - Netlify Docs
Configuring a base directory instead of prepending something like cd SUBDIRECTORY_PATH && to your build command ensures a more efficient build.
Read more >
Things I wish I had known when I started JavaScript monorepo ...
The reason is simple: all packages of the monorepo will be recursively installed by running npm install from monorepo root.
Read more >
Inside the pain of monorepos and hoisting - Jonathan Creamer
So, most monorepo structures have a root package.json , and a packages folder. ./packages/foo/ ./packages/foo/node_modules ./packages/barΒ ...
Read more >
Monorepos - Trunk Based Development
If you cannot overhaul the directory structure of your entire repository, you should not entertain a monorepo. Lock-step deployments?#. OK, so it is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found