What is the best way to install a standalone npm workspace that relies on both external packages and other workspaces?

I successfully set up a project utilizing npm workspaces and Typescript Project References, following the same structure as this example repository: https://github.com/Quramy/npm-ts-workspaces-example.

In this setup, all node_modules are stored in the root-directory/node_modules directory, with symlinks created to the packages for direct referencing from another package.

While this configuration works well during development, I am facing challenges with deployment. How can I deploy a single workspace when all node modules are located in the root directory? The dist folders do not contain the node modules, and running npm i installs all dependencies and creates symlinks.

What is the best way to build a single workspace that depends on specific packages and another workspace without including all dependencies from every workspace?

The project structure is as follows:


├── node_modules/
├── package-lock.json
├── package.json
├── packages
│   ├── package-1
│   │   ├── dist
│   │   │   ├── helper.d.ts
│   │   │   ├── helper.js
│   │   │   ├── helper.js.map
│   │   │   ├── main.d.ts
│   │   │   ├── main.js
│   │   │   └── main.js.map
│   │   ├── package.json
│   │   ├── src
│   │   │   ├── helper.ts
│   │   │   └── main.ts
│   │   └── tsconfig.json
│   └── package-2
│       ├── dist
│       │   ├── index.d.ts
│       │   ├── index.js
│       │   └── index.js.map
│       ├── package.json
│       ├── src
│       │   └── index.ts
│       └── tsconfig.json
├── tsconfig.build.json
└── tsconfig.json

Answer №1

When it comes to navigating through npm workspaces, I don't have a specific solution at hand. However, if you make the switch from npm to pnpm, there is a useful command that fulfills this exact function: deploy

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

Using Typescript: What is the best way to convert a variable into a specific element of an array?

List of Strings: const myStrings = ["one", "two", "three"]; const newString = "two"; The variable newString is currently just a string, but I would like its type to be an element of myStrings. Is there a way to achi ...

ReactJS Provider not passing props to Consumer resulting in undefined value upon access

Hey there! I've been facing an issue with passing context from a Provider to a consumer in my application. Everything was working fine until suddenly it stopped. Let me walk you through a sample of my code. First off, I have a file named AppContext.t ...

Encountered an issue when trying to install truffle with the command "npm i truffle -g"

Encountered an unidentified error while trying to install Truffle on my computer... https://i.stack.imgur.com/6GuxV.png Initially, there was an unexpected issue with Python. However, after installing Python, a new error arose npm ERR! code 1 npm ...

Is it possible for Typescript to deduce keys of a generic type within conditional statements?

Within my function, I have a parameter that accepts an enum value as T and a generic type Data<T> which selects between two different data types. I expected to be able to access properties of type BarData within a conditional statement that should m ...

Having trouble changing the node version using NVM?

I can't seem to switch my current node version using nvm Here's the output from nvm debug nvm --version: v0.37.2 $TERM_PROGRAM: vscode $SHELL: /bin/bash $SHLVL: 2 whoami: 'john' ${HOME}: /Users/john ${NVM_DIR}: '${HOME}/.nvm&ap ...

Creating a dedicated class or module specifically designed for handling import and export tasks is a highly efficient approach towards stream

Exploring different ways to import multiple classes into a single class file: import myClass1 'pathto1'; import myClass2 'pathto2'; import myClassn 'pathton'; Seeking a simpler method using one file (class export) with al ...

What are the steps to troubleshoot a Node Package Manager library in Visual Studio Code?

I have created a Typescript library that I plan to use in various NodeJS projects. The source code is included in the NPM package, so when I install it in my projects, the source also gets added to the node_modules folder. Now, during debugging, I want to ...

Can you explain the meaning of the "invalid" tag that appears in the `npm list`?

After reviewing the snippet from npm list output below: ... ├─┬ <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="80e7ecefe2c0b6aeb0aeb2">[email protected]</a> invalid │ ├─┬ <a href="/cdn-cgi/l/emai ...

The import path for Angular 2 typescript in vscode mysteriously vanished

After upgrading VSCode, I noticed a change in the way namespaces are imported when I press Ctrl + dot. Now, the paths look like: import { Store } from '../../../../node_modules/@ngrx/store'; instead of import { Store } from '@ngrx/store&a ...

Can you provide guidance on generating a definition file for a JavaScript library without a tsd in TypeScript version 2.2.2?

I am currently in search of a comprehensive example or best practices for creating a definition file (not necessarily a tsd) for a JavaScript library that does not have one in @types or included with the package. While I have managed to put together a bas ...

Troubleshooting Typescript Compilation Error in React - Cannot assign type 'Element' to type 'FunctionComponent<{}>'

The code snippet originally utilized - import { Create } from '@material-ui/icons'; <DroppableFolder count={draftsCount} sidebarOpen={open} folderId={FolderType.Drafts} Icon={Create} name="Dr ...

Building a theme with TypeScript in React

As I embark on my React project, I've been tasked with creating a CSS using TypeScript while referring to the color palette diagram provided below. Utilizing createMuiTheme to build the theme, I've realized that there are various possible conditi ...

What is the best way to retrieve specific values from an ng-bootstrap modal?

I am working on a website that includes an ng-bootstrap modal. This modal contains two <select> elements with dynamic items, allowing the user to click on two buttons. One button simply closes the modal and sets the value of the Reactive Form to new ...

Is it possible to use line breaks to differentiate properties?

The handbook addresses The handbook states that you can separate properties using , or ;, and the last separator is optional in either case. Is it possible to use line breaks to separate object properties like this? If so, where is this information docu ...

React Native Async Storage: displaying a blank page issue

I am facing an issue while attempting to save my data locally using AsyncStorage, specifically with the getData method. const storeData = async (value: string) => { //storing data to local storage of the device try { await AsyncStorage.setItem(& ...

Tips for successfully passing an argument to an npm script while including a leading slash

Within my package.json file, I have defined some scripts: "scripts": { "build": "webpack-cli --mode production", "build:dev": "webpack-cli --mode development", } I am trying to pass an additional ...

To prevent callback hell in Angular 2 when making multiple HTTP requests

Back in my Angular 1 days, I used to nest HTTP calls and react to their results like this: this.$qSessionPromise .then(() => { return this.Init(); }) .then(() => { return this.Services.GetData1("id1"); }) .then((data: model.DataType1) => ...

What is the best way to extract data from a proxy in VUE3?

Currently, I am utilizing the ref() function to store data retrieved from Firebase. However, when attempting to filter and retrieve a single record, the outcome is not as expected. Instead of returning a single object, something different is being displaye ...

Experiencing issues transferring a file to a different folder using mongoose

Here is the code snippet I am currently using to locate the document that needs to be duplicated to another collection: public updateConfigWithType(req: Request, res: Response) { configs.findOne({'companyInfo.uniquecompanyid': req.params.id}, ...

Function modifies global variable

What could be causing the global variable to change when using the function write_ACK_ONLY()? I'm passing the array rxUartBuffer to write_ACK_ONLY() as data = new Array(20), but upon checking the Log Output, it seems that the function is also modifyin ...