# Deploy to NPM has no local\_dir available

**URL:** <https://travis-ci.community/t/deploy-to-npm-has-no-local-dir-available/2513>\
**Category:** Deployment\
**Tags:** deployment\
**Created:** [March 3, 2019, 5:12pm UTC](https://travis-ci.community/t/deploy-to-npm-has-no-local-dir-available/2513 "2019-03-03T17:12:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![merlosy](https://avatars.discourse-cdn.com/v4/letter/m/7feea3/32.png) [@merlosy](https://travis-ci.community/u/merlosy)\
**Post date:** [March 3, 2019, 5:12pm UTC](https://travis-ci.community/t/deploy-to-npm-has-no-local-dir-available/2513/1 "2019-03-03T17:12:20Z")

</div>

Hi,  
I’m having trouble deploying to NPM ([https://github.com/merlosy/ngx-material-file-input/blob/master/.travis.yml](https://github.com/merlosy/ngx-material-file-input/blob/master/.travis.yml)).  
As much as I want to use it, I just cannot specify a dist directory! This is a big issue for me since I have multiple deploy provider running.  
the npm publish command is actually more helpful.

If someone has a solution, that’d be very helpful! or a fix on the deploy provider?

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [March 4, 2019, 1:04am UTC](https://travis-ci.community/t/deploy-to-npm-has-no-local-dir-available/2513/2 "2019-03-04T01:04:06Z")

</div>

This is the code for the `npm` provider: [https://github.com/travis-ci/dpl/blob/master/lib/dpl/provider/npm.rb](https://github.com/travis-ci/dpl/blob/master/lib/dpl/provider/npm.rb) Hope it will help you understand what is happening.  
You didn’t give any error details, the build log in particular, so can’t say anything else.

---

<div class="post-metadata">

**Author:** ![merlosy](https://avatars.discourse-cdn.com/v4/letter/m/7feea3/32.png) [@merlosy](https://travis-ci.community/u/merlosy)\
**Post date:** [March 5, 2019, 9:38pm UTC](https://travis-ci.community/t/deploy-to-npm-has-no-local-dir-available/2513/3 "2019-03-05T21:38:44Z")

</div>

Thanks for the reply but I don’t see how it can help.  
I have a deploy step with 3 different providers(gh-pages, github release, npm release), each deploy a different artifact or set of files.  
The issue with `before_script` is that it applies to all 3 of them. (Right?)

Logs of my last attempt: [https://travis-ci.org/merlosy/ngx-material-file-input/jobs/500943603](https://travis-ci.org/merlosy/ngx-material-file-input/jobs/500943603)

The 3rd deploy is deploying everything to npm, but I wanted to deploy just the `dist/material-file-input` folder

thanks

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [March 6, 2019, 12:07am UTC](https://travis-ci.community/t/deploy-to-npm-has-no-local-dir-available/2513/4 "2019-03-06T00:07:02Z")

</div>

According to [https://github.com/travis-ci/dpl/blob/master/lib/dpl/provider/npm.rb#L33](https://github.com/travis-ci/dpl/blob/master/lib/dpl/provider/npm.rb#L33) , it runs `npm publish` in the project root, passing only API key and tag if specified. All that happens next is hence up to the utility.

According to [https://docs.npmjs.com/files/package.json](https://docs.npmjs.com/files/package.json) , you can specify files to deploy with the “`files`” parameter or, as per [https://docs.npmjs.com/cli/publish](https://docs.npmjs.com/cli/publish), exclude files with a `.gitignore` or `.npmignore`. It looks like with this, the tree will still be rooted at the project root – i.e. if you specify e.g. “`dist/material-file-input/*`” it will create the directories `dist/material-file-input` and their content under them. If you rather need the deployed tree to be _rooted_ at `dist/material-file-input`, you need to move `project.json` (and other appropriate metafiles if any) there and use the `script` provider:

```auto
deploy:
    script:
        - cd dist/material-file-input
        - NPM_API_KEY=<api_key> npm publish <etc>

```

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [March 6, 2019, 2:08am UTC](https://travis-ci.community/t/deploy-to-npm-has-no-local-dir-available/2513/5 "2019-03-06T02:08:21Z")

</div>

There are a couple of viable options.

1. Split your build into stages; the `test` stage that runs the tests, and the `deploy` stage with three different jobs, each running different deployments. One of them (one for npm) can naturally execute `cd …` in `before_deploy` step.
2. Write a PR that adds the `local_dir` option to the `npm` provider. This seems straightforward.

(Note that the `script` provider does not accept multiple commands.)

---

<div class="post-metadata">

**Author:** ![filips123](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/filips123/32/579_2.png) [@filips123](https://travis-ci.community/u/filips123)\
**Post date:** [August 2, 2019, 3:58pm UTC](https://travis-ci.community/t/deploy-to-npm-has-no-local-dir-available/2513/6 "2019-08-02T15:58:17Z")

</div>

> [@BanzaiMan](#):
>
> Write a PR that adds the `local_dir` option to the `npm` provider. This seems straightforward.

I created PR [#1023](https://github.com/travis-ci/dpl/pull/1023) for this. If this is merged, when it will be released on Travis CI?
