Missing node_modules when deploying AngularJS2 application to Bluemix - npm

We're trying to deploy an AngularJS2 application to bluemix but we're missing the folder "node_modules" after the application was deployed to the server. We're using npm to build the application.
I found the following post that is mentioning the problem: (https://developer.ibm.com/answers/questions/181207/npm-install-within-subdirectory-not-creating-node.html)
My question would now be: what's the recommended best practice?

I believe you are installing the node modules using npm install, you also should save those module in your package.json file which you can do that by npm install --save.
The recommended best practice would be to Setup a Build Pipeline.
There could be 3 stages or more:
Build Stage: It builds the app so doing things like npm install there so your folder node_modules gets created for you.
Test Stage: Tests the app so doing things like npm test would run all the tests in your app
Deploy Stage: Once build and deploy stage runs successfully, Deploy will actually deploy the app to the Bluemix domain.

Related

Netlify is not deploying create-react-app

Apparantly it takes 30 seconds to deploy a react app on netlify!
https://www.netlify.com/blog/2016/07/22/deploy-react-apps-in-less-than-30-seconds/
I have followed exactly the following steps :
create-react-app hello-world2
cd hello-world2
npm run build
npm install netlify-cli -g
netlify deploy
The CLI then gives me a bunch of options. I selected the "." for publish directory. Is that right?
This is what is in my console :
I then go to :
https://5ed0fcc54e316210489aa68c--hellowworld2.netlify.app/
and I get :
How is this possible if I am following the steps exactly?
Create-React-App will build your app into production files that it places in the ./build folder - see docs here.
You need to tell Netlify to look in there, so set publish directory to build.

Gitlab CI: create dist folder inside repository?

I just recently started using gitlab CI to automate some build/deploy steps. It works perfectly to build docker images etc, but I was wondering if it's possible to create a folder in the repository during a build step? For example I'm now making an npm utility package, but I'm just importing it in my other projects via a private gitlab repo (using deploy token), but the code of the util package is written in es6 and needs to be transpiled to commonJS to be used in the other packages. Manually I can run npm run build and it will output a dist folder with the transpiled code.
I was trying (and researching) if it's possible to automate this build process using .gitlab-ci but so far I couldn't find anything.
Anyone know how I can achieve this and/or if this is possible?
Thanks in advance!
Not sure if I got your question correctly, so add more details if not.
When your CI build creates new folders or files, they are written to the task runner's file system (no surprise here, I assume).
If you want to access these files from Gitlab's web UI you can define them as artifacts in your build job (see https://docs.gitlab.com/ee/user/project/pipelines/job_artifacts.html)
Your build job would look something like that (pseudo code written by memory, not tested on Gitlab):
build:
script:
- npm run build
artifacts:
paths:
- dist/
expire_in: 1 week
UPDATE If you want to upload the build artifact to an NPM registry, you could just build and push together.
build:
script:
- npm run build
- npm publish <PARAMETERS>

npm install when deploy Octopus

I need to create node_modules in the root app when deploy new version using Octopus
How can I create a run script using a new octopus step? I try:
npm install
But I get error when execute the script step
'The remote script failed with exit code 1'
Any ideas?
Your build system should be handling that for you. The node_modules directory should then be included in your application package, but ideally, this should also be bundled to reduce the number of files that your application is dependant on.
If you do need to run this as part of a deployment, then you would need NodeJS and npm installed on the server that is executing the deployment step (either the Octopus server itself or a worker instance if using workers).
For more information check out this blog post

Bamboo Continuous integration with yarn test (JEST framework)

I am very new to Atlassian Bamboo build CI. I want some help from you guys.
My Job is to make a continuous integration build plan for my reactjs application. So I started with Bamboo.
Now my application test cases are written in JEST framework.
In my (local machine) react application when I test the test cases locally I use the following command
"yarn test"
I installed yarn inside Bamboo by "npm install yarn"
My requirement is whenever I will merge my code in GitHub an automatic build will be triggered in Bamboo and if the test cases are passed then it will deploy the code..Now the build plan is getting triggered when ever I merge the code it GitHub (Because in step 1 of the build plan I made a job to checkout code from my GitHub repo)
But I am not understanding how to tell the build plan to run "yarn test" my test cases using JEST framework.
The question might look very easy for you guys...so please help me..
The agent (local or remote) running your builds needs:
Nodejs installed
npm installed - typically by the nodejs install
yarn installed globally (npm i -g yarn)
Then you can use as a script task to run the yarn test command.
You can build on this be seeing if there are plugins that abstract the script task into some sort of yarn task and you can look at processing the test results in Bamboo so that the builds show the test results and fail/pass the build accorindly.

Run a Vue.js project in server without " npm run dev " command?

After installing vue cli globally by running npm install -g vue-cli, I have installed all the modules in the project folder "myBlog" by running npm install and can run the project in my local environment by using npm run dev. But when I am going to move this project in the live server is this is the right way to run the batch program (npm run dev) continuously or there are other ways to run the project without running npm run dev continuously?
It's not Vue specific but you also should be able to run npm run build which generates production bundles in /dist subfolder of your project. You are supposed to copy this folder to the production server and configure the server so that it serves dist/index.html for every URL.
If you are using the "webpack", "webpack-simple" or "pwa" template there is a dedicated command for creating the production build, which allows a static hosting (with no need to run any npm process in the server):
npm run build
It will create a dist folder which content you can upload to the root of your server.
Some more info about:
"webpack" template:
https://vuejs-templates.github.io/webpack/commands.html#npm-run-build
"webpack-simple":
https://github.com/vuejs-templates/webpack-simple#webpack-simple
"pwa": https://github.com/vuejs-templates/pwa#whats-included
Very simple. To launch a VueJs project, you must type "npm run serve".