Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,361,708
Community Members
 
Community Events
168
Community Groups

TypeError: (intermediate value).slice(...).reverse(...).flatmap is not a function when building app

Edited

 

Hi there I'm trying to build and deploy my react app using bitbucket pipelines, I have built and deploy other ones, but for some reason this one is throwing me the following error 


----------------------


Building the project 👷🏽‍♂️

----------------------

yarn run v1.22.5

$ env-cmd -f .env.development react-scripts build

Creating an optimized production build...

Failed to compile.

TypeError: (intermediate value)(intermediate value)(intermediate value).slice(...).reverse(...).flatMap is not a function

error Command failed with exit code 1.

info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Connection to $SERVER_ADRESS closed.

✖ Execution failed.

 

 

I can build the project locally, and I can actually manually deploy it as well when I connect to the server and run `yarn run build:develop`, but for some reason it breaks on the pipeline.

Here is my `bitbutcket-pipeline.yml` for reference.

 

image: node:15.2.1

pipelines:

branches:

"{master,main}":

- step:

name: Deploying development 🚀

caches:

- nodeall

- yarn

script:

- echo 'Connecting to remote server to update repo'

- node --version

- npm --version

- pipe: atlassian/ssh-run:0.2.2

variables:

SSH_USER: $USER

SERVER: $SERVER_ADRESS

COMMAND: "cd smiling-scripts && bash admin-deploy-dev.sh"


definitions:

caches:

nodeall: ./node_modules

yarn: /usr/local/share/.cache/yarn

 



EDIT: 23.08.2022

Hi @Theodora Boudale

thanks for the reply. Yes that's the error I get from the command pipe: atlassian/ssh-run:0.2.2 (and - pipe: atlassian/ssh-run:0.4.1) now that I have changed it.

 

I don't get any errors when I connect to my server and build it manually. It builds without errors. Same as when I do it locally.

 

I can't understand why is only braking on the pipeline script. I have deleted the `node_modules` and reinstalled everything on the server but now I get the following error on the pipeline (so at least is not the same one 🙃, but still unable to build)

 


yarn run v1.22.5 $ env-cmd -f .env.develop react-scripts build /home/$USER/$USER-admin-develop/node_modules/eslint-webpack-plugin/node_modules/jest-worker/build/index.js:110 _ending; ^ SyntaxError: Unexpected token ; at Module._compile (internal/modules/cjs/loader.js:723:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

 




1 answer

0 votes

Hi @DS,

 

  • You provided at the beginning of your post some output with an error. Is this output from the command pipe: atlassian/ssh-run:0.2.2 of your yml file?

  • If you connect to your server as the same user in the variable $USER, switch to the directory smiling-scripts, and then execute bash admin-deploy-dev.sh, what output do you get?
    Do you get the same output and error as in the pipe?

I would also suggest updating the version of the pipe to the newest one (0.4.1)

- pipe: atlassian/ssh-run:0.4.1

as you're using a version that is quite older.

 

Kind regards,
Theodora

Hi @Theodora Boudale  I updated my question. I tried to 'reply' to your message, but for some reason bitbucket keeps telling me 'You have posted a similar answer in the last few days please review your answer or change the text'

Hi @DS,

Thank you for the update. You mentioned that you don't get any errors when you connect to your server and build it manually.

Are you running the script admin-deploy-dev.sh located in smiling-scripts directory in order to build when you connect to your server?

It's not very clear from your reply if you run the same script on your server, or if e.g. you are running build commands directly without executing this specific script. Earlier in your post you mentioned that you ran `yarn run build:develop` on your server instead of executing the script.

Could you please let me know if the build is successful when you execute the script admin-deploy-dev.sh on the server? Just to check if the error seems to be specific to the script or not.

Kind regards,
Theodora

Hey @Theodora Boudale

 

 So both things actually work in the server:

  - if I run the build via the `admin-deploy-dev.sh` script ->  the application builds

  - if I run the build via `yarn run build:develop` ->  the application also builds.


What I found out after trying and debugging more is that when I downgrade the `react-scripts` pkg to `@v4.0.1`, the application will build normally, however some styles and other stuff will not be available in the final product (this of course is not desirable)


Right now I'm `react-scripts @V.5.01` when  I leave as it is, it is when I get the following error:


/home/$USER/$USER-admin-develop/node_modules/eslint-webpack-plugin/node_modules/jest-worker/build/index.js:110

  _ending;

         ^
SyntaxError: Unexpected token ;

    at Module._compile (internal/modules/cjs/loader.js:723:23)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

  

Hi @Dante Solis,

Thank you for the info.

Could you please try one more thing, run the pipe with MODE: 'script' and COMMAND: './smiling-scripts/admin-deploy-dev.sh' and let me know if this works or if you still get errors (and if so, what errors)?

- pipe: atlassian/ssh-run:0.4.1
variables:
SSH_USER: $USER
SERVER: $SERVER_ADRESS
MODE: 'script'
COMMAND: './smiling-scripts/admin-deploy-dev.sh'

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

3,499 views 3 10
Read article

Atlassian Community Events