2
votes

I built web app using react.js, and I want to make build and deploy on the server using FTP on every commit. For that purpose, I configure bitbucket pipeline, but I get an error on build react app.

I tested my local machine by running "npm run build" command and it run successfully without any error, but on pipeline, I get the following error:

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-05-16T13_18_01_726Z-debug.log

Here is bitbucket-pipeline configuration:

image: node:8.11.1-slim

pipelines:
default:
- step:
script:
- echo "This script runs only on staging branch"
branches:
staging:
- step:
caches:
- node
script: 
- npm install
- node --version
- npm --version
- npm run build
- apt-get update
- apt-get -qq install git-ftp
- git ftp init --user $FTP_USERNAME --passwd $FTP_PASSWORD -v $FTP_HOST

I checked node and npm version are same as I using on my local machine.

1
Is the user executing the pipeline the same? With the same environment variables? The same .npmrc?VonC
@VonC yes I execute same pipeline and environment varsQamar Azam
So the nprmc used is the same? Can you check by adding a first step in the pipeline with sh(id -a; echo ${HOME})VonC
@VonC I dont have any npmrc file, what's it and should i add it ?Qamar Azam
docs.npmjs.com/files/npmrc: I was wondering if that could differ between your environment and Jenkins'VonC

1 Answers

3
votes

Replace the command npm run build to CI=false npm run build

this will resolve your problem