简体   繁体   中英

Using npm workspaces in Azure CI/CD pipelines to build React web app?

I'm currently taking a React web app (built by me and previously shelved), bringing it forward to the present, then taking the reusable bits and folding them into a React Native app I'm building new. The web app, now subjugated within a package controlled by the workspace wielder, will be deployed via CI/CD on Azure currently.

To manage the monorepo I'm setting out to fashion from the current repo, I'm wanting to do this via the simplest tool that requires the smallest code and dependency delta: npm workspaces (new to npm v7) — as opposed to something much heavier and less "stock" like lerna . However, it seems that Azure's latest available Node.js version is 14, which defaults to the latest minor/patch version of npm v6. Can anyone confirm to me that, if I build the web app's build sequences within a package, they'll work on Azure's CI/CD at present? Or even just give me more color around this?

You are correct in that azure defaults to node 14 and npm 6. But you can add a step to your pipeline that simply installs npm 7 before running any other steps.

Add a step with a custom task. Set it to run a custom npm command, something like this (sorry for formatting, answering from phone):

-task Npm@1 inputs: command: “custom” customCommand: “install -g npm@7”

After that your pipeline will use npm 7 for the entire run, and thus have workspace support.

Then you can proceed with running all npm commands with workspace support just as you do locally.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM