npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

npm runs into problem in Windows PowerShell, as long as there exists an auto-run bat file implictly changing PWD.


This post was originally named “[errno -4058] When running in Windows 10 PowerShell, npm treats non related neighbour folder named npm@xxxxxx as an impediment. Thus it complains “no such file or directory” in the current folder.”.
But shortly after it was posted, I found out that this was a false positive. It was not npm!

The Update of the Truth

It’s reasonable for me to turn off BAT echo temporarily inside the auto-run .bat file. So I had no idea that it gets executed also during the npmjs scripts execution processes.
Later, I deliberately added an echo statement into the said .bat file. Then I saw with my own eyes that the .bat file got run again every time I tried to ran some npm commands, in the PowerShell, but not in the CMD.


Why didn’t CMD environment get affected? Well, it’s not so important to me.

Sorry again for posting misleading contents before!

-------------------- original opinion below ---------------------------------

The original content below are not all true, especially the conclusion.

The story

I’d like to run npm run serve for a really normal/regular Vuejs project.

When I:

  1. chose the PowerShell over Windows 10 to run my npm commands

  2. cded into the correct project folder

  3. and typed npm run serve.


  1. npm complained that

    npm ERR! path D:\p\dev\wulechuan\personal\npm@wulechuan\package.json
    npm ERR! code ENOENT
    npm ERR! errno -4058
    npm ERR! syscall open
    npm ERR! enoent ENOENT: no such file or directory, open 
    npm ERR! enoent This is related to npm not being able to find a file.
    npm ERR! enoent
    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\Users\wulechuan\AppData\Roaming\npm-cache\_logs\2019-03-22T16_05_05_860Z-debug.log

My setup looks like this

The folder structure looks like this:

  \___ p
       |\___ dev
       |       \___ wulechuan
       |                |\___ personal
-------|---look-here----|----->   |\___ npm@wulechuan
       |                |         |           \___ <...>
       |                |         |
       |                |          \___ web-sundries
-------|---and-here-----|--------------->   |\___ my-lovely-vuejs-project
       |                |                   |
       |                |                    \___ <...>
       |                | 
       |                 \___ served
       |                         \___ <...>
        \___ creative
                 \___ <...>

As we can tell from the folder hierarchy shown above, when we traverse the folder tree, we encounter npm@wulechuan first, and web-sundries\my-lovely-vuejs-project a bit later than that.

The npm might treat the folder whose name starts with npm@ being a very special one. because when I was inside the my-lovely-vuejs-project folder or sub folder of it, and ran any of npm run, npm i or npm run serve, I got unexpected results. Among them:

This problem issued in no other environments but PowerShell only

Other environments

By the way, is it the Microsoft or the npm group that I shall submit an issue to?
Seriously asking!

Other facts

Problem can be solved this way (NOT TRUE!)

When I finally doubted the naming of the npm@wulechuan. I tried these:

  1. I renamed the npm@wulechuan into npm_at_wulechuan, problem solved in PowerShell.

  2. I deliberately created a new folder nm@wulechuan (no more letter p), npm ran smoothly in PowerShell.

    Note that this new and empty folder is still at a precedent place of the traverse.

  3. I deliberately renamed the nm@wulechaun into npm@wulechuan, problem raised again in PowerShell.

Personally, if npm@xxxxx is not a reserved naming space, I do not want to rename my folder into something else. Obviously I’m forced to do so now.:cry:

Thanks for the update. Good debugging trying different shells. Glad you worked it out!

Thanks for your encouragement.