My project currently contains 2 apps. The first is the application Backend (NestJS) and the second is the client (VueJS).
The current folder structure follows:
Root (NestJS)
./client/ (VueJS)
When I am deploying my app to Azure App Service I am using the azure/webapps-deploy#v2 action. It's procedure is to run npm install in the root of the project but I need it to also run in the sub project containing the client packages. How can this be done? Are there any arguments to provide the webapps deploy action to include that addition npm install command?
You could try add the commands directly in your workflow:
- name: npm install, build, and test
run: |
npm install
npm run build --if-present
npm run test --if-present
cd ./client/mern_azure_example # go to your client package
npm install # run npm install under your client package
But it takes very long time.
Related
Is there a way to automate deployment of Angular application to NodeJS or onPrem WebServer using Azure Devops PipeLines.
For Angular apps, you can include Angular-specific commands such as ng test, ng build, and ng e2e. To use Angular CLI commands in your pipeline, you need to install the angular/cli npm package on the build agent.
- script: |
npm install -g #angular/cli
npm install
ng build --prod
Note:
On Microsoft-hosted Linux agents, preface the command with sudo,
like sudo npm install -g.
https://learn.microsoft.com/en-us/azure/devops/pipelines/ecosystems/javascript?view=azure-devops&tabs=example#angular
I have a bitbucket pipelines yml that I have step for running my test script and a step to run a serverless deploy script. Do I need to npm install at each step or will the first npm install carry through and suffice for each subsequent step. Further than that, what is happening under the hood? I know Docker container is created; does each step just update the container?
- step:
name: Test and Build
script:
- npm install --no-package-lock
- npm run test
- step:
name: Deploy Serverless
script:
- npm i serverless -g
- npm install --no-package-lock
- npm run deploy
Can you implement it like the documentation: https://confluence.atlassian.com/bitbucket/caching-dependencies-895552876.html
The functionality is there. Let me know if it doesn't work for you still.
Each step in the pipe creates a separate docker container which pulls in your branch. Using the cache option will allow your pipe to skip the install when building the container for the second step by pulling node_modules from the cache. You must still include the npm install line in each step to tell the pipe to use the cache if it exists.
I looking into Angular universal and trying to get my head around deployment.
Github https://github.com/angular/universal-starter
It has Angular 2 Universal + TypeScript 2 + Webpack 2
When I run the command
npm run build
I get the following structure
**Client**
0.bundle
0.bundle.js.map
main.bundle
main.bundle.js.map
**Server**
0.index
0.index.js.map
index
index.js.map
How do I deploy this to a server?
Install dependencies
Run npm install in your terminal at the root of universal-starter
Run the NodeJS backend
Run npm run build:ssr && npm run serve:ssr after npm install has finished, this will host a local nodejs server here: http://localhost:4000 (you can put that in your browser)
Before either of these steps ensure you have NodeJS and NPM installed (NPM comes with the newer builds of NodeJS)
Is there a way to load an npm module as the main application?
I'm used to using git to load some application like:
git clone https://github.com/me/myapp.git
cd myapp
npm install
npm install always puts dependency modules under the node_modules path.
How would I deploy a stand-alone application as a node module?
Is there something equivalent to:
npm install myapp
cd myapp
npm start
Create a github new project let say myapp
Clone the project
git clone https://github.com/me/myapp.git
Generate the package.json
Update the your code logic
let create file index.js add some code
module.exports = (name) =>name;
Create a npm account
https://www.npmjs.com/signup
login npm
go to the terminal type below the command
npm login
Publish the npm package
npm publish https://github.com/me/myapp.git
Install the package
npm install myapp
Start import the the module
let name =require('myapp')
console.log(name("hello world"));
In my Jenkins job I want to build a JavaScript app using Grunt. The Jenkins build scripts creates a build directory (if it doesn't already exist), changes to that directory and runs:
npm install grunt
npm install grunt-zip
grunt --gruntfile=[something]
(Of course grunt-cli is installed globally.) When I build the job, the first statement causes Grunt and dependencies to be pulled down as expected. However, the job then terminates successfully:
Archiving artifacts
No emails were triggered.
Finished: SUCCESS
The second npm install is not run. Any idea why the script is terminating after running npm install instead of continuing to the subsequent statements?
So it turns out that npm is a batch file, not an executable, so it needs to be invoked using call from the Jenkins script:
call npm install grunt
i would recommend not using the local grunt / nodejs install, but instead getting jenkins to do this for you!
it's much easier and means there's less coupling to system specific installs and variables.
steps:
a) use nodejs jenkins plugin + get it to install nodejs on machine/grunt-cli -> Jenkins integration with Grunt
b) populate your package.json with any nodejs dependances required, eg grunt/grunt-zip etc
c) when running grunt just do a "npm update" before "grunt" command
that way your not doing explicit npm install, it's all configured from your package.json, and your build scripts will be less brittle, and your developers can use the same steps as the build server, eg "npm update;grunt" locally same as build server
For future googlers:
use command chaining for this.
This works:
npm install && npm install install grunt-zip
This wont work:
npm install
npm install grunt-zip