THIS IS A FALSE POSITIVE. IT WAS NOT NPM! SORRY!
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
I enabled a auto-run
.batfile via Windows registry
%UserProfile%\my-auto-setup.batruns every time a new console window is opened.
Inside the said
.batfile, these exists a
CDstatement to conveniently goto a specific folder. And the said folder happens to be named
npm@wulechuan, which looks like special to nodejs npmjs program. But it’s really not. This sign misled me before.
.batfile, althought seems have nothing to do with the PowerShell environment, does have a side effect to PowerShell! When I
cded to my vuejs project folder, everything looks find. But when I tried to run
npmcommands, PowerShell was implictly affected by the auto-run
.batfile, thus invisibly
cded to the
npm@wulechuanfolder and then tried to run my desired
npmcommand in the incorrect folder.
I found out this because I later encountered the same problem even if there wasn’t a folder named
npm@xxxxxat all, after I orginal post.
When I removed the single line of
cdstatement inside of the
.batfile. Problem disappeared. I mean npmjs commands ran smoothly even inside PowerShell.
It’s reasonable for me to turn off BAT
echotemporarily inside the auto-run
.batfile. So I had no idea that it gets executed also during the npmjs scripts execution processes.
Later, I deliberately added an
echostatement into the said
.batfile. Then I saw with my own eyes that the
.batfile got run again every time I tried to ran some
npmcommands, 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.
I’d like to run
npm run serve for a really normal/regular Vuejs project.
chose the PowerShell over Windows 10 to run my npm commands
cded into the correct project folder
npm run serve.
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 'D:\p\dev\wulechuan\personal\npm@wulechuan\package.json' 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:
d: \___ 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 i or
npm run serve, I got unexpected results. Among them:
npm iseemed ok but it actually created a
package-json.lockunder the totally unrelative
npm@wulechuan, instead of the
pwd, aka the
npm runprint nothing and quit quietly.
npm run serve, you already knew the story.
This problem issued in no other environments but PowerShell only
I switched to Windows CMD (DOS like), npm ran smoothly.
I switched to Git Bash or Cygwin, npm ran smoothly.
I switched back to Windows PowerShell, npm ran unexpectedly.
By the way, is it the Microsoft or the npm group that I shall submit an issue to?
- I tried two versions of npm. At first the version was 6.5.0. After some struggling, I updated npm to version 6.9.0 by running
npm i -g npm.
Neither version of npm worked with the present of the
Problem can be solved this way (NOT TRUE!)
When I finally doubted the naming of the
npm@wulechuan. I tried these:
I renamed the
npm_at_wulechuan, problem solved in PowerShell.
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.
I deliberately renamed the
npm@wulechuan, problem raised again in PowerShell.
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.