NPM Install Error | Text File is Busy, Unlink - laravel

Getting this error when running sudo npm install --force --no-bin-links within project folder. Below is the error I'm receiving. It looks like it keeps renaming some of the nodes. I go into the actual folder and remove the #s at the end, but when I run the install again, it just re-adds them...not sure what's going on.
Thank you!

"ETXTBSY is a file sharing violation at the system level, and it indicates that another process has the file already opened and holds the lock for it." (source)
It means that npm is trying to overwrite a locked file. You have to stop the process holding the lock to be able to overwrite that file.
The process PID can be found with
fuser -u <package.json.somenumber

Related

-Bash Shell Script "No such file or directory"

Pretty new to coding and I am running into an error I've never seen before and would really appreciate any help navigating this :( Thank you!
I wanted to delete nvm, so I removed the folder following the advice given on StackOverflow. That FINALLY successfully deleted node from my mac (wanted to uninstall because I was running into dependency errors). The I used brew install to reinstall node. I can find the path to the node file (using which node). However when I run node -v I get the following bash (shell script??) error: -bash: /Users/Cindy/.nvm/versions/node/v12.14.1/bin/node: No such file or directory
I also followed #1219 and went into my bash_profile to delete the lines related to nvm. Now I don't know how to move forward with this.
I just want to be able to download node and run it properly to prepare for an interview in React and JS but I ran into these nasty bugs instead and morale is low. I'm lost now and I'm not sure if I just completely ruined my computer.

Vue CLI Fails to install for Mac Mojave

I get the following error when setting up a new Vue project:
npm install -g #vue/cli
Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
I got around this error by changing permissions for two directories:
Set permissions to Everyone - Read / Write for
/usr/local/lib/node_modules
/usr/local/bin
Open Finder.
Press Command +Shift+G. A dialog box opens.
Enter the path and click Go
Right-click the directory and select Get Info
Click the lock icon to allow changes and enter your credentials
In the Sharing & Permissions section change everyone to Read & Write
Click the cog icon and select Apply to enclosed items from the drop down
Confirm the prompt
Reference Article:
https://forum.vuejs.org/t/vue-cli-installation-fails-on-macos-mojave-10-14/45712/5
As far as I know, its not just a Vue Cli issue but can happen for any node module.
Often this happens if you installed NPM as an administrator or using Sudo. You can usually get around it by doing something like sudo npm install xxx-package-xxx But that really just compounds the problem down the road when lots of things need elevated privileges.
In my case uninstalling and re-installing Node + NPM with a new package (not the ones included with MacOS) kind of helped but I eventually ended up nuking my OS and installing everything fresh.

Stuck at ".android/repositories.cfg could not be loaded."

brew cask install android-sdk
==> Caveats We will install android-sdk-tools, platform-tools, and build-tools for you. You can control android sdk packages via the
sdkmanager command. You may want to add to your profile: 'export
ANDROID_HOME=/usr/local/share/android-sdk'
This operation may take up to 10 minutes depending on your internet
connection. Please, be patient.
==> Downloading https://dl.google.com/android/repository/tools_r25.2.3-macosx.zip
Already downloaded:
/Users/ishandutta2007/Library/Caches/Homebrew/Cask/android-sdk--25.2.3.zip
==> Verifying checksum for Cask android-sdk
==> Warning: File /Users/ishandutta2007/.android/repositories.cfg could not be loaded.
Create the file! try:
mkdir -p .android && touch ~/.android/repositories.cfg
Actually, after waiting some time it eventually goes beyond that step.
Even with --verbose, you won't have any information that it computes anything, but it does.
Patience is the key :)
PS : For anyone that cancelled at that step, if you try to reinstall the android-sdk package, it will complain that Error: No such file or directory - /usr/local/share/android-sdk.
You can just touch /usr/local/share/android-sdk to get rid of that error and go on with the reinstall.
This happened on Windows 10 as well. I resolved it by creating an empty repositories.cfg file.
For Windows 7 and above go to C:\Users\USERNAME\.android folder and follow below steps:
Right click > create a new txt file with name repositories.txt
Open the file and go to File > Save As.. > select Save as type: All Files
Rename repositories.txt to repositories.cfg
Creating a dummy blank repositories.cfg works on Windows 7 as well. After waiting for a couple of minutes the installation finishes and you get the message on your cmd window -- done
Windows 10 Solution:
For me this issue was due to downloading and creating an AVD using Android Studio and then trying to use that virtual device with the Ionic command line.
I resolved this by deleting all existing emulators and creating a new one from the command line.
(the avdmanager file typically lives in C:\Users\\Android\sdk\tools\bin)
List existing emulators:
avdmanager list avd
Delete an existing emulator:
avdmanager delete avd -n emulator_name
Add system image:
sdkmanager "system-images;android-24;default;x86_64"
Create new emulator:
sdkmanager "system-images;android-27;google_apis_playstore;x86"
I had the same error on OSX Sierra, but in my case the ~/.android folder was owned by root (from a previous install)
I changed the ownership to my User and now it works.
I used mkdir -p /root/.android && touch /root/.android/repositories.cfg to make it works

npm hangs on any command

I installed last version of Node.js (12.2 x64 windows)
After I run cmd as administrator and try to call any npm command (except npm -v), cmd window is hanging. After Ctrl+C it returns
Terminate batch job (Y/N)?
I was trying to left cmd for several hours but it didn't give some results.
It is strange because node.exe process is consuming CPU and memory quite hard.
I was trying to reinstall node.js several times without success.
I can't even get some debug information.
I faced such issue on my VM which I was using by connecting via rdp. Same version installed on my laptop works ok. On my VM I had Kaspersky antivirus, but after switching it off I got same result.
Did somebody face such issue? Is there some way to get more information problem?
Could you please recommend me some way to resolve?
I've finally resolved my issue.
According to suggestion from our local read me file
Node.js (with NPM) Note: On windows server machines, instead of node modules been installed at user %APPDATA% path, its better to install at a global path e.g c:\npm. This could be acheived by the npm command: $ npm config set prefix 'c:\npm' This is not required on individual developer's machine.
I've executed npm config set prefix 'c:\npm'.
As result it added prefix="'c:\\npm'" to my .npmrc file
This make node.js really crazy. It takes me about an hour to debug all these js scripts npm.js code.js etc... to find that it calls mkdirp with 'c:\\npm'\etc and it loop process forever.
If anyone will encounter this problem in the future you need to find the npmrc file delete it and delete all configurations for node, delete node as well and install it, this should fix that.
when deleting node some of the configurations aren't deleted so you have to delete it manually.
It happenned for me too : I installed node only for my user on Windows 10, and managed to use npm by calling it using the full path "c:\Program Files\nodejs\npm"
I solved by using "c:\Program Files\nodejs\npm" config set prefix "c:\Program Files\nodejs" (setting the prefix to the full path to npm)
And the result was :
λ cat c:\Users\<my_user_name>\.npmrc
prefix=c:\Program Files\nodejs
Now eveything works fine.
It's if the prefix is not set correctly.
Just want to point out to those commenting -if you can't get access to the command line npm, then you can't run npm config, obviously.
Open up powershell and type notepad $HOME/.npmrc, and edit the line where it says prefix=... and change it to a valid one.
For clarity, when you call:
npm config set prefix 'c:\npm'
you are required to have the ' wrapping the path, but you need to remove them from the .npmrc file so that npm commands will work. So your resulting line in .npmrc file should look like:
prefix="c:\\npm"
Just delete the .nprmc file at User/%UserProfile% and now try the command if it dosents work even reinstall once.

Why does npm need sudo for EVERYTHING?

I don't know how I've managed it but npm seems to need sudo for absolutely every command, even npm help does not work without sudo. If I use a command without sudo, I do not see am EACCESS error, but instead my terminal session hangs and then just closes that tab (I use iTerm on Mac).
I have tried changing the ownership of my local .npm folder, outlined here and also done the same on my /usr/local/bin folder where node is installed but none of these allow me to just run npm without sudo, even when installing local packages...! It seems to me that something has screwed along the way, can anyone help?
Many thanks
I encountered the same error after a fresh install of 0.12.4 today; this solved the problem for me:
sudo chown -R $(whoami):admin /usr/local/lib/node_modules
In my particular case, I noticed that this folder was owned by '{some-large-integer-account}:wheel'...YMMV
If that doesn't solve it, take a look at the ownership of the folders that are being blocked as mentioned in the EACCESS error trace. If you're not sure what the ownership should be, you can usually infer it from the sibling dirs' ownership.
I had this as well on my machine. What I did to fix it (there are probably much less extreme ways) was to completely remove npm, and then did a fresh installation node.js (with which npm is included) from http://nodejs.org/ making sure I didn't install as root. That then allowed me to use npm without root (except for global installs).
Take ember project for example, I give all related project directory root:
neil#neil-System-Product-Name:~/Projects/ember-quickstart$ sudo chown -R $(whoami) /home/neil/Projects/ember-quickstart/
neil#neil-System-Product-Name:~/Projects/ember-quickstart$ ember s
Could not start watchman
Visit https://ember-cli.com/user-guide/#watchman for more info.
Livereload server on http://localhost:7020
Build successful (10679ms) – Serving on http://localhost:4200/
Slowest Nodes (totalTime => 5% ) | Total (avg)
----------------------------------------------+---------------------
Babel (18) | 7561ms (420 ms)
Concat (8) | 1872ms (234 ms)
Rollup (1) | 629ms
Use the below option.
Open the terminal and cd to your Home directory and run the below command.
mkdir "${HOME}/.npm-packages"
Then this command after that.
npm config set prefix "${HOME}/.npm-packages"
Next, open your .zshrc file using the open -t .zshrc command and add the following to it.
NPM_PACKAGES="${HOME}/.npm-packages"
export PATH="$PATH:$NPM_PACKAGES/bin"
# Preserve MANPATH if you already defined it somewhere in your config.
# Otherwise, fall back to `manpath` so we can inherit from `/etc/manpath`.
export MANPATH="${MANPATH-$(manpath)}:$NPM_PACKAGES/share/man"

Resources