question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nodejs - New-Item creating a file instead of a folder

See original GitHub issue

Hi,

I’ve had a problem recently with a personal NodeJS DockerFile inspired from yours. I installed bower globally but it started failing some time ago, complaining about “bower” not being a known command.

Long story short, I fixed it by modifying the path creation line : New-Item -path $env:APPDATA -Name 'npm' -itemType "directory" instead of New-Item $($env:APPDATA + '\npm')

I’ve added a test command to the Dockerfile : RUN dir C:\Users\ContainerAdministrator\AppData\Roaming\npm which confirms that npm was a 0-length file.

Am I the first to notice this error ? Honestly I don’t understand how or why bower started not working… I have proof the same lines just worked 6 months ago, maybe with an older npm version. I can do a pull request if you confirm it needs fixing.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
michaelPf85commented, Dec 29, 2017

See PR #249, it’s been a month but I’ve finally found some time to do it !

0reactions
michaelPf85commented, Nov 28, 2017

I assume that global npm packages are installed in the nodejs directory if the current user has the permissions to do it, or AppData if it does not. The documentation isn’t exactly helpful on this subject…

By the way I think I found where my errors really come from : randomly, npm or bower just won’t install the required packages. I suppose it’s linked to my random DNS problems, those commands might just fail silently when name resolution goes awry, and I was misled by the npm folder misunderstanding.

Thanks for your time, I’ll submit a PR to simplify the npm path management.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create Directory When Writing To File In Node.js
Can anybody help me in finding out how to make Node.js create the directory structure if it does not exits for writing to...
Read more >
Use Node.js to To Create Directories and Files
The first argument is the path including the directory where you want the file to be created. · The second argument is the...
Read more >
New-Item creates a file instead of directory/folder
Hi everyone -. I'm stuck with New-Item cmdlet creating a file instead of directory even though I specifically add -ItemType "directory".
Read more >
How to create files and directories with Node.js [15 of 26]
Creating files is a convenient way to export data in your applications, but you also need to make sure you do not overwrite...
Read more >
Working with folders in Node.js
Create a new folder. Use fs.mkdir() or fs.mkdirSync() or fsPromises.mkdir() to create a new folder.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found