Npm install hangs and fails on windows 10 - node.js

My npm installs on windows 10 with the most up to date node.js and npm stable versions always fail when I enter the command npm install while cd'd into my project folder. This specific folder was set up with express as described here. Below is the relevant portion of the verbose failure log. I have no idea what is going wrong, can anyone help?
1315 verbose stack Error: ENOENT: no such file or directory, rename 'C:\Users\carte\Desktop\Queue\Queue\node_modules\amdefine' -> 'C:\Users\carte\Desktop\Queue\Queue\node_modules.amdefine.DELETE'
1316 verbose cwd C:\Users\carte\Desktop\Queue\Queue
1317 verbose Windows_NT 10.0.16299
1318 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Users\carte\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "install" "--verbose"
1319 verbose node v8.11.0
1320 verbose npm v5.8.0
1321 error path C:\Users\carte\Desktop\Queue\Queue\node_modules\amdefine
1322 error code ENOENT
1323 error errno -4058
1324 error syscall rename
1325 error enoent ENOENT: no such file or directory, rename 'C:\Users\carte\Desktop\Queue\Queue\node_modules\amdefine' -> 'C:\Users\carte\Desktop\Queue\Queue\node_modules.amdefine.DELETE'
1326 error enoent This is related to npm not being able to find a file.
1327 verbose exit [ -4058, true ]

I know this is old, but I had currently this problem and couldn't find answers, so I post my solution, in case it helps someone else.
My problem was that I have npm install on C:\ and my project (or git folder) in G:\.
Moving my folder from G:\ to C:\Desktop and running npm install solved it for me.
I am not sure if it was because of moving it to C:\ or if it was because of moving it outside git-folder.
Edit: before that I actually cleaned npm cached using --force.
I'm using npm v6.7.0 and node v10.15.1

which npm version you are using, basically thses errors come with npm version below 5.5. For CLI
supporting information:
npm -v prints: 5.6.0
node -v prints: 8.9.1
npm config get registry prints: https://registry.npmjs.org/
Windows, OS X/macOS, or Linux?: Windows 10

In my case, npm install got stuck because I had TypeScript watching file in this directory. So the solution is to stop any tool that might be watching files and try again to install.

Related

When upgrading node from 6 to latest, npm i fails with ENOENT in react native project

When upgrading to newer versions of npm from 6.14 to latest on react native project
Using node 14, nvm to switch node versions, ideally i'd like to go to node 16, but a similar issue happens regardless of 14 or 16 when updating npm in particular.
I'm also using homebrew on mac M1
I notice the Jetify command asks me:
Jetifier found 1390 file(s) to forward-jetify. Using 8 workers...
Need to install the following packages:
pod
Ok to proceed? (y)
when i select y, npm i fails. I've cleared cache's and removed node_modules. normal cache clearing attempts don't seem to work.
npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path /Users/user/.npm/_npx/a0ca5f5666585aa2/node_modules/pod/node_modules/pm2/bin/pm2
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/Users/user/.npm/_npx/a0ca5f5666585aa2/node_modules/pod/node_modules/pm2/bin/pm2'
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! /Users/user/.npm/_logs/2022-01-28T21_51_28_303Z-debug-0.log
npm ERR! code 254
npm ERR! path /Users/user/repos/MyApp/My-MobileApp
npm ERR! command failed
npm ERR! command sh -c npx jetify && cd ios && npx pod install && cd .. && ./node_modules/.bin/patch-package
Here is part of the complete log -
3325 timing reify:rollback:retireShallow Completed in 0ms
3326 timing command:exec Completed in 42372ms
3327 verbose stack Error: ENOENT: no such file or directory, chmod '/Users/user/.npm/_npx/a0ca5f5666585aa2/node_modules/pod/node_modules/pm2/bin/pm2'
3328 verbose cwd /Users/user/repos/MyApp/MyApp-MobileApp/ios
3329 verbose Darwin 21.2.0
3330 verbose argv "/Users/user/.nvm/versions/node/v14.18.3/bin/node" "/Users/user/.nvm/versions/node/v14.18.3/lib/node_modules/npm/bin/npm-cli.js" "exec" "--" "pod" "install"
3331 verbose node v14.18.3
3332 verbose npm v8.4.0
3333 error code ENOENT
3334 error syscall chmod
3335 error path /Users/user/.npm/_npx/a0ca5f5666585aa2/node_modules/pod/node_modules/pm2/bin/pm2
3336 error errno -2
3337 error enoent ENOENT: no such file or directory, chmod '/Users/user/.npm/_npx/a0ca5f5666585aa2/node_modules/pod/node_modules/pm2/bin/pm2'
3338 error enoent This is related to npm not being able to find a file.
3338 error enoent
3339 verbose exit -2
3340 timing npm Completed in 42533ms
3341 verbose unfinished npm timer reify 1643406718315
3342 verbose unfinished npm timer reify:build 1643406730346
3343 verbose unfinished npm timer build 1643406730346
3344 verbose unfinished npm timer build:deps 1643406730347
3345 verbose unfinished npm timer build:link 1643406730354
3346 verbose unfinished npm timer build:link:node_modules/pod 1643406730356
3347 verbose code -2
3348 error A complete log of this run can be found in:
3348 error /Users/user/.npm/_logs/2022-01-28T21_51_28_303Z-debug-0.log
It looks like the error is related to not finding the pm2 package from pod dependency.
Not sure if this will work properly with npx, you might need to install pod globally to get this working.
npm install pod -g
pod install // instead of npx pod install
https://www.npmjs.com/package/pod#installation
Try npm rebuild they say to use "only when you upgrade the node version and must recompile"
hello i once faced this type of issue and issue was actually because pm2 or some other package or processes on old node which was used in your app wasnt found in the updated node version
Reinstall your pm2 package and other package used by your old node in your code again and try again
let me know if this helps you

Unable to run any child processes with npm

I'm trying to install packages for a work repo, however whenever I try to run the install, once it gets to the child processes (like running install scripts for a package) I get a weird spawn error. I'm assuming it's having issues running the child processes.
Some information:
Windows machine
Node v12.22.3 and npm v6.14.13 (I've tried node 14)
Tried using bash, windows terminal, cmd prompt, and powershell (all with admin)
Error code seems to be a 4058 but I'm not sure what it can't find
It was working fine just last week, now suddenly I can't get anything done. I've tried the following:
Turning off the Work AV
Removing node_modules and package-lock
Running npm cache clear --force and npm cache verify
Uninstalling node and reinstalling
Completely uninstalling nvm and node and reinstalling
The error I see is:
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn =
npm ERR! file =
npm ERR! path =
npm ERR! errno ENOENT
npm ERR! root# prepare: `husky install`
npm ERR! spawn = ENOENT
npm ERR!
npm ERR! Failed at the root# prepare script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\dhers\AppData\Roaming\npm-cache\_logs\2021-07-19T18_28_56_807Z-debug.log
Do note this is NOT a husky problem, anything that runs a child process script seems to have this error happen.
I've never seen this before and I'm unable to fix it with the googling I've done. Here is some information from the npm log:
59 silly lifecycle root#~prepare: Args: [ '-c', 'husky install' ]
60 info lifecycle root#~prepare: Failed to exec prepare script
61 silly lifecycle root#~prepare: Returned: code: -4058 signal: null
62 info lifecycle root#~prepare: Failed to exec prepare script
63 verbose stack Error: root# prepare: `husky install`
63 verbose stack spawn = ENOENT
63 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
63 verbose stack at onErrorNT (internal/child_process.js:470:16)
63 verbose stack at processTicksAndRejections (internal/process/task_queues.js:84:21)
64 verbose pkgid root#
65 verbose cwd C:\Users\dhers\Documents\Development\Work\seamless
66 verbose Windows_NT 10.0.19042
67 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i"
68 verbose node v12.22.3
69 verbose npm v6.14.13
Has anyone seen this before? I'm really hoping I'm just overlooking something super simple. Any help would be appreciated because this has me halted right now.
Maybe try the following:
Clean the npm cache
npm cache clean --force
Check the npm version you're using. Maybe it should be updated:
npm install -g npm#latest
Try with another version of the package huskey
For this specific scenario, try to skip huskey install through adding
export HUSKY_SKIP_INSTALL=true
to the npm install cmd just to see whether the problem persists with other prepare scripts.
Add the script to the postinstall hook instead of the prepare hook to see if the problem is from the hook.
Go up level by level in your working directory and make sure there are no other directories containing /node_modules directory or package.json or a pakcage-lock.json file. Sometimes npm considers it the root of the project.
Make sure your system environment variables PATH contains the following values:
%SystemRoot%
%SystemRoot%\system32
%SystemRoot%\System32\Wbem
C:\Program Files\nodejs\
Also, make sure your User environment variables PATH contains the following value:
C:\Users\dhers\AppData\Roaming\npm
Note that you need to restart your computer for the changes to take effect.
Delete package-lock.json and node_modules
Execute npm cache clean --force
Execute npm install or yarn install
Then again run
maybe the wrong is your dependencies, check in your package.json
and your npm local is not the correct
"dependencies": {
"npm": "^7.5.6",
then you can try with yarn, yarn install

Error during npm start files not found

I'm new to electron and I am trying to get it up and running on my machine. I am trying to follow along with a tutorial titled 'Creating Your First Desktop App With HTML, JS and Electron'.
I set up the folder where I wanted the files to be downloaded to and extracted them to it but after running npm intall (I did the npm start) an error showed up. this log came back. Please help me understand how to properly install or give file names need to make electron run.
I am using a windows 10 x64 machine.
here is the log
0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Users\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'start' ]
2 info using npm#3.10.5
3 info using node#v4.4.7
4 verbose stack Error: ENOENT: no such file or directory, open 'c:\Users\Desktop\WestHelper\package.json'
4 verbose stack at Error (native)
5 verbose cwd c:\Users\Desktop\WestHelper
6 error Windows_NT 10.0.10586
7 error argv "C:\Program Files\nodejs\node.exe"
"C:\Users\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "start"
8 error node v4.4.7
9 error npm v3.10.5
10 error path c:\Users\Desktop\WestHelper\package.json
11 error code ENOENT
12 error errno -4058
13 error syscall open
14 error enoent ENOENT: no such file or directory, open 'c:\Users\Desktop\WestHelper\package.json'
15 error enoent ENOENT: no such file or directory, open 'c:\Users\Desktop\WestHelper\package.json'
15 error enoent This is most likely not a problem with npm itself
15 error enoent and is related to npm not being able to find a file.
16 verbose exit [ -4058, true ]
the idea behind NPM is to install packages from package.json shipped with application, so everybody can download dependencies and packages used in project. Because of this, when you run npm install, it searches current directory for file named package.json and tries to read dependency tree from it. The message you posted says, it could not find any in directory c:\Users\Desktop\WestHelper\package.json
If I've found correct tutorial, there is a section called How it’s made where the content package.json file is present.
Hope it helped, have a wonderful day.
T

Error with installing browsersync for node js through command prompt

A little background: I have a Windows 10 laptop with 8.3 gigs of usable space(6.3 gigs are python, so 2 gigs of usable space), so I install and download everything onto an external hard drive. Unfortunately, my previous external hard drive started malfunctioning and physically falling apart after less than 6 months, so I've been in the process of moving files and reinstalling programs to my new hard drive. Recently I joined a MOOC that asked me to download Node JS and install browsersync on it.
I installed Node JS and tested it and npm with -version, and both were installed. I closed and reopened the cmd. However, when I ran npm install -g browser-sync it gave me the following: cmd errors
The first error is due to a typo, but the second error is the real one.
Here is the true error in text:
Microsoft Windows [Version 10.0.10240]
C:\Users\Bracklinn>npm install -g -browser-sync
npm ERR! addLocal Could not install C:\Users\Bracklinn
npm ERR! Windows_NT 10.0.10240
npm ERR! argv "D:\\Programs\\NodeJs\\node.exe" "D:\\Programs\\NodeJs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "-browser-sync"
npm ERR! node v4.4.7
npm ERR! npm v2.15.8
npm ERR! code EISDIR
npm ERR! errno -4068
npm ERR! syscall read
npm ERR! eisdir EISDIR: illegal operation on a directory, read
npm ERR! eisdir This is most likely not a problem with npm itself
npm ERR! eisdir and is related to npm not being able to find a package.json in
npm ERR! eisdir a package you are trying to install.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Bracklinn\npm-debug.log
I tried uninstalling and reinstalling, googled it a bunch of times, and just ended up wasting 2 hours. I think it has something to do with my cmd is in my computer drive but node.js is on my hard drive. So I've turned here for help.
Thanks in advance!

Consuming node module in a tar file exposed by team city artifact

So there is currently a team city server which packages a node module for internal use and exposes it via an artifact. The artifact is a tar.gzfile which contains package.json, dist/**/*, readme.md files/folders.
In my package.json dependencies (for a dependent package) I have something like:
"some-module": "http://some-address/guestAuth/repository/download/some-project/.lastSuccessful/some-module.tar.gz"
Which resolves correctly to the tar.gz file, and I can download and open it all fine when doing it manually. However the odd thing is that when I do an npm install npm blows up with the error:
npm ERR! tar.unpack untar error C:\Users\Blah\AppData\Local\Temp\npm-10684-84325da0\some-server\guestAuth\repository\download\some-project\.lastSuccessful\some-module.tar.gz
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v4.2.6
npm ERR! npm v3.5.3
npm ERR! path C:\Users\Blah\AppData\Local\Temp\npm-10684-84325da0\unpack-f18f9e1b
npm ERR! code EEXIST
npm ERR! errno -4075
npm ERR! syscall mkdir
npm ERR! EEXIST: file already exists, mkdir 'C:\Users\Blah\AppData\Local\Temp\npm-10684-84325da0\unpack-f18f9e1b'
npm ERR! File exists: C:\Users\Blah\AppData\Local\Temp\npm-10684-84325da0\unpack-f18f9e1b
npm ERR! Move it away, and try again.
I am super confused as I have tried doing npm cache clean and deleting my temp folder in the appdata/local nothing seems to stop this error.
I have looked over lots of related issues like:
https://github.com/npm/npm/issues/6309
https://github.com/npm/npm/issues/5133
However nothing seems to work, I am on windows 10 64-bit using npm 3.5.3 and node 4.2.6.
Has anyone else achieved the same sort of thing or is there something I am missing here as it is a blocker on a current project and none of us seem to have any idea why its blowing up.
Solved it.
So the issue was that I was not putting a containing folder in my tar file, so if you add a root folder and have your package and other files underneath that, it all works.

Resources