Flatten NPM Packages using Bamboo on Windows 2012 R2

As part of one of our builds on Bamboo, I want to flatten the npm packages using the npm package flatten-packages. To do so, I need to execute "flatten-packages" from the parent folder of the node_modules folder. Attempting to do this with a script in Bamboo fails (also fails from command prompt when remoted into build server). Attempting to do it as a Node task leaves me confused about what I should be executing, and all that I try has been to no avail in actually flattening the packages. As a Node task, I have tried running the bin/flatten file as well as lib/flatten.js, but neither work. So, the basic question is, how can I execute "flatten-packages" (which works when I do it on my own computer) as part of an automated build on a Windows 2012 R2 server? Thanks in advance.

2 answers

1 accepted

1 vote
Accepted answer

Just to share the resolution so it can help other customers, according to what we discussed on the support request you opened, you "resolved it by using the fully qualified path to the command in the script task in the Bamboo build."

Feel free to add more details here.


This might be old. But just letting others know how i made it work:

I installed flatten-packages on server globally using command: npm install -g flatten-packages

Noted down the installation path. It was: C:\Users\Administrator\AppData\Roaming\npm

Now if flatten-packages command is run from any folder on server, it would look for definition of this command in folder, if not found it would look for it in system paths.

I checked Control Panel > System > Advanced System Settings > Environment Variables > System variables > Variable value. The above installation path was not there. I added it there with semicolon separator.

Now flatten-packages command can be run from any folder on server. (So it will work from the build folder.)

I configured nodejs tasks in Bamboo UI this way:

  1. npm task with install command.
  2. Grunt task to run unit tests.
  3. JUnit parser task to parse test results.
  4. Script task to flatten packages. (Script location: inline. Script body: flatten-packages)

According to me, flatten-packages as the last task on windows server is a must have task because it lets clean-up processes delete the node_modules gracefully.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Statuspage

Introducing Statuspage Getting Started guides! First up: What is Statuspage?

Over the next several weeks we'll be sharing some of our Getting Started guides here in the community. Throughout this series of posts, we'd love to hear from customers and non-customers ab...

186 views 4 1
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you