Execute Yarn commands from the main directory

In the midst of my project, I have various sub projects - one of which is dedicated to JavaScript. My intention is to employ this JavaScript project as a task runner for the entire endeavor using gulp. However, I've hit a snag in the process.

The layout of my project is structured like so:

root 
     |_
       js-client 
                |_
                   package.json
                |_
                   node_modules
     |_
       go-server

After research, I discovered that utilizing .yarnrc allows me to designate an alternative location for node_modules. As such, I relocated package.json to the root directory and crafted the following .yarnrc file:

--modules-folder client/node_modules

Upon executing yarn install from the root directory, modules were effectively installed in the designated location. Yet, upon running yarn build, an error surfaced:

[09:46:17] Local modules not found in ~/Documents/Projects/root
[09:46:17] Try running: npm install

It appears that --modules-folder only serves as a flag for install and not for run. Is it feasible to achieve what I desire, or should I create a distinct yarn project for task execution? I prefer not to rely on global settings to accomplish this.

Answer №1

The solution is to utilize the command --cwd when running yarn

By doing this, you can alter yarn's current working directory to your desired location

For instance, in the given scenario, if you want to execute yarn build starting from the main directory, you should enter:

yarn --cwd js-client build

Answer №2

Have you included a build script in your package.json file?

If not, it is recommended to add one in order to customize the default behavior. Consider starting the script with this command: cd client && yarn build.

Additional Note:

root
--package.json (including the build script)
--client

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

employing rowspan functionality within a JavaScript application

How can I achieve a table layout where the first two columns are fixed for only one row and the remaining rows are repeated 7 times? Additionally, is there a way to make the bottom border of the last row thicker? Check out the expected table for reference. ...

Socket.on seems to be malfunctioning

Currently, I am in the process of creating a message board for practice purposes and have successfully implemented notifications and a chat application using socket.io. My next goal is to add basic video call functionality, but I have encountered some dif ...

I'm intrigued: what type of syntax is Facebook's polling service utilizing in the callback?

While monitoring the Network Monitor on Chrome's developer tool, I observed how Facebook updates content on their news feed. All AJAX responses start with the following: for (;;);{"__ar":1,"payload":[]} I'm curious about what the for(;;); piec ...

The backspace key is unresponsive following the use of a jQuery class

Using a specific class for an input field: Here is the code for the input field: <?php echo $this->Form->input('duration', array('class'=>'input-large text-right number-field','value'=>'0&apo ...

Divergent find function behavior in jQuery when applied to div or tbody

I've encountered an issue while using the jQuery find selector by Id with a div and tbody. Let me simplify my problem for better understanding. HTML <div id='iamdiv'>HELLO</div> <table> <tbody id='iamtbody' ...

Develop a program that retrieves necessary components, sets up, and launches a web browser

I am running an application with a node server and I want to achieve the following: npm start This should install both node dependencies and bower dependencies, and then open a browser window. Is it possible to do this without using gulp or grunt? Howe ...

PRISMA.IO - Wiping clean data during production database migration

I need some help with a Prisma and sqlite database issue. Whenever I run the command "npx prisma db push", all my data gets erased. I've searched through the official documentation and on Google, but haven't found a solution to migrate my product ...

npm will be set up to download and install all packages within the directory /usr/local/lib/node

After setting up node.js 0.8.14 on my Ubuntu 12.10, I decided to create a directory within my home directory with a sub directory called node_modules. My intention was to install some local node modules there. However, whenever I try to run npm install ...

Using Vue.js to group JSON arrays multiple times

I have a program that I utilize to import a CSV data file and then convert it into JSON format. The resulting JSON structure is as follows: { "Class": "Cultivated Mushrooms", "Type": "Shii-take", "Grade": "Medium", "LvH": "SP", "Description": " ...

Give Jquery a quick breather

My goal is to have my program pause for 3 seconds before continuing with the rest of the code. I've been researching online, but all I can find are methods that delay specific lines of code, which is not what I need. What I would like to achieve look ...

Interfaces and Accessor Methods

Here is my code snippet: interface ICar { brand():string; brand(brand:string):void; } class Car implements ICar { private _brand: string; get brand():string { return this._brand; } set brand(brand:string) { this. ...

How can I extract an array of objects from an array of arrays containing objects?

Here is the array I am currently working with: let findAllSegmentProjectMediaFilesXref = [ { it: 0, bt: 0, items: [ { mute: false, startPosition: 10, endPosition: 20, ...

Sending data from a JSP page to a JavaScript function

I am working on a script that dynamically adds text boxes based on a specific time interval. <script type="text/javascript> $(document).ready(function() { var data = $('#data').val(); var counter = 1; var d = new Date(); va ...

Adjusting the line-height in CSS dynamically based on the length of characters using jQuery

I am facing an issue with the Twitter widget on my website where our company's latest tweet sometimes gets cut off if it exceeds a certain length. I want to dynamically adjust the line-height CSS property of the element based on the tweet's chara ...

Append a constant string to the conclusion of the route parameter

Using React Router v6.4.1, I am aiming for a consistent conclusion to a series of dynamic routes. Specifically, I want my product detail routes to always end with "-product". For example, if the path is "/shaver-900-product", it should activate my Produc ...

Error encountered in Node/Express application: EJS partials used with Angular, causing Uncaught ReferenceError: angular is not defined

I seem to be missing something important here as I attempt to incorporate ejs partials into a single-page Angular app. Every time I try, I encounter an Uncaught ReferenceError: angular is not defined in my partial. It seems like using ejs partials instead ...

Reset the dropdown menu in React by setting a disabled option as the default selection

One issue I'm facing is trying to reset some dependent dropdowns that are controlled by react state. The functionality works fine, except when the default option is set as disabled. I came across this code snippet in a fiddle from another stackoverfl ...

Error during live-server npm installation: symlink issue persists even with root/admin privileges

In my current project, I am following a tutorial on AngularJS from the book titled "Unraveling AngularJS 1.5 (With Over 130 Complete Samples" by István Novák, which stipulates the need for installation of Node.js. The appendix of this book provides comma ...

An issue occurred while trying to serialize cookies retrieved in getServerSideProps

I am currently working on a project using Reactjs with Next.js. I recently implemented a login module using cookies, but encountered an issue when trying to serialize the .cookies object returned from getServerSideProps. The error message states that undef ...