Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

package.json files field is ignored in Bitbucket npm publish pipeline

Justin George September 23, 2022

Trying to publish to private npm repo from bitbucket. The bundle is built and added to a folder called dist. 

 

image: node:14

pipelines:

default:

- parallel:

- step:

name: Build and Test

caches:

- node

script:

- npm install

- npm test

- step:

name: Lint the node package

script:

- npm install eslint

- npx eslint .

caches:

- node

branches:

master:

- parallel:

- step:

name: Build and Test

caches:

- node

script:

- npm install

- npm run build

- step:

name: Security Scan

script:

# Run a security scan for sensitive data.

# See more security tools at https://bitbucket.org/product/features/pipelines/integrations?&category=security

- pipe: atlassian/git-secrets-scan:0.5.1

- step:

name: Deploy to Production

deployment: Production

script:

# Bump versions before publishing

- npm --no-git-tag-version version "2.0.$BITBUCKET_BUILD_NUMBER" -m "Upgrade to new version"

# Publish package

- pipe: atlassian/npm-publish:0.3.2

variables:

NPM_TOKEN: $NPM_TOKEN

 

Problem is that publishing to npm, dist folder is not published. 

Folder structure after building (locally and expected)

- package-name
- dist
- index.ts
- package.json

But with the Bitbucket pipeline, only package.json is added to the package, and dist is ignored.  

Inside package.json, I've added the property

"files": [
"dist"
]

According to npm docs , files always take precedence over gitignore and npmrc. 

Verified with npm publish --dry-run locally to make sure the right files are built. And it is working fine in that case. 

 

I was able to make it work by adding entries in npmignore files (not adding dist in npmignore and adding in gitignore). But this creates a lot of redundancy. 

Will Bitbucket pipeline consider files attribute in package.json?

1 answer

1 accepted

0 votes
Answer accepted
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 30, 2022

@Justin George hi.Thanks for question. Try to use folder parameter according to the docs:

script:
  - pipe: atlassian/npm-publish:0.3.2
    variables:
      NPM_TOKEN: $NPM_TOKEN
      FOLDER: 'dist'

 Regards, Igor

Justin George October 27, 2022

Needed a few changes to get this working.

- Used artifacts to retain the dist folder

- used LOCAL_PATH  instead of FOLDER

Mladen Oršolić April 8, 2023

would you post a whole example pleae, not sure what would artifacts part look like
EDIT: 
figured it out, and if it'll help anyone else :

  branches:
    production:
      - parallel:
        - step:
            name: Build and Test
            caches:
              - node
            script:
              - npm install
              - npm run rollup
              - npm test
            artifacts:
              - dist/**                                       <<< the artifacts part



Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events