# Bug: NPM not working correctly

**URL:** <https://discuss.circleci.com/t/bug-npm-not-working-correctly/428>\
**Category:** Build Environment\
**Created:** [November 7, 2015, 8:37am UTC](https://discuss.circleci.com/t/bug-npm-not-working-correctly/428 "2015-11-07T08:37:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![drazisil](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/drazisil/32/24029_2.png) [@drazisil](https://discuss.circleci.com/u/drazisil)\
**Post date:** [November 7, 2015, 8:37am UTC](https://discuss.circleci.com/t/bug-npm-not-working-correctly/428/1 "2015-11-07T08:37:11Z")

</div>

[https://circleci.com/gh/drazisil/jpm-report/33](https://circleci.com/gh/drazisil/jpm-report/33)

Starting tonight, npm is acting very strange.

1: the node command in the machine section is taking a LONG time to decide if it is installed  
2: npm install seems to fail.  
3: sudo npm says it doesn’t exist

Thoughts?

---

<div class="post-metadata">

**Author:** ![DevendraMeena1](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/devendrameena1/32/302_2.png) [@DevendraMeena1](https://discuss.circleci.com/u/DevendraMeena1)\
**Post date:** [November 7, 2015, 9:52am UTC](https://discuss.circleci.com/t/bug-npm-not-working-correctly/428/2 "2015-11-07T09:52:10Z")

</div>

If you need to authenticate with npm before downloading the  
dependencies, you could store the npm credentials in the  
secure environment  
variables  
and then use the following script to perform the authentication:

```auto
#!/bin/bash
set -o nounset
set -o errexit

npm login <<!
$NPM_USERNAME
$NPM_PASSWORD
$NPM_EMAIL
!

```

---

<div class="post-metadata">

**Author:** ![drazisil](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/drazisil/32/24029_2.png) [@drazisil](https://discuss.circleci.com/u/drazisil)\
**Post date:** [November 7, 2015, 10:16am UTC](https://discuss.circleci.com/t/bug-npm-not-working-correctly/428/3 "2015-11-07T10:16:32Z")

</div>

good tip, but i’m not trying to login to npm at all, this is npm install, not npm publish.

---

<div class="post-metadata">

**Author:** ![DevendraMeena1](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/devendrameena1/32/302_2.png) [@DevendraMeena1](https://discuss.circleci.com/u/DevendraMeena1)\
**Post date:** [November 7, 2015, 10:49am UTC](https://discuss.circleci.com/t/bug-npm-not-working-correctly/428/4 "2015-11-07T10:49:36Z")

</div>

If you are able to login to npm without any error confirms that there is no error in dependencies: cache\_directories .  
If it throws an error then i believe you have to clear the cache directories where NPM is installed . Please refer this : [https://circleci.com/docs/how-cache-works](https://circleci.com/docs/how-cache-works) .

---

<div class="post-metadata">

**Author:** ![drazisil](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/drazisil/32/24029_2.png) [@drazisil](https://discuss.circleci.com/u/drazisil)\
**Post date:** [November 7, 2015, 4:02pm UTC](https://discuss.circleci.com/t/bug-npm-not-working-correctly/428/5 "2015-11-07T16:02:12Z")

</div>

I tried the ‘without cache’ build option, so I don’t think it is a cache issue, and I’m still not sure why I would need to login to npmjs if I’m not using private modules. (what if I didn’t have an account there?)

Either way, it was likely a connection issue somewhere between npmjs and the build chain, the issue has resolved itself.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:37am UTC](https://discuss.circleci.com/t/bug-npm-not-working-correctly/428/6 "2018-06-18T11:37:35Z")

</div>


