A bunch of errors when running npm install - npm

When I run npm install on my xampp laravel setup I get a bunch of errors. log is LONG and shown below. I don't even know where to start
I've tried deleting my node_module folder (that was a random guess, nothing changed)
I've tried to run npm install -g (didn't work either)
I'm installing the root of my project and I've got a composer.json file.
Error log:
Errorlog link

Try just deleting the node-sass folder in node_modules (if it's there), then run npm install node-sass#4.9.2 --save, and run npm install again!

Related

NPM insists on using the wrong registry URL

Using NPM to install dependencies, including one that is stored in Verdaccio running locally.
Somehow NPM is stuck attempting to load the Verdaccio dependency from localhost even though the command to install from the corrected location has been run npm install --save --registry http://CORRECT-URL ...
Using rm -rf node_modules package-lock.json and removing the dependency from package.json, then running the install again - still DOES NOT WORK. Every time the install command completes, package-lock.json STILL uses localhost to resolve the registry.
Removing localhost from ~/.npmrc and running npm set registry http://CORRECT-URL also didn't help.
Please help. Where is NPM remembering localhost and insisting on using it???
UPDATE - Using npm install -ddd
Attempted to use npm install -ddd to see where npm is picking up the package. The output shows the CORRECT-URL, but when it is done, package-lock.json still lists localhost.
Note all of the following:
Removed all references to the PACKAGE from package.json and package-lock.json
Verified no references to localhost in either file
Removed node_modules/PACKAGE_DIR with rm -rf
Removed PACKAGE from node_modules/.package-lock.json
Searched for .npmrc and npmrc in the build tree and found two empty files:
node/node_modules/npm/docs/public/configuring-npm/npmrc
node/node_modules/npm/.npmrc
~/.npmrc has 2 entries for the CORRECT_URL in the following forms:
//:/:_authToken="<AUTH_TOKEN>"
registry=http://:/
Stumbled upon this post while trying to debug the exact same situation. What ended up solving this for me was to blow out package-lock, run npm rebuild, then npm install --registry . Hope this helps someone in the future!

npm doesn't uninstall packages

I've been trying to remove some packages that I installed with npm but it doesn't remove them. After running npm uninstall -g package the package is still executable in my terminal and it is still in the path where npm binaries are being installed.
Also, why is npm installing packages in ~/.local/share/npm/bin/ ? It's the first time that I've seem npm installing packages there. I had a problem a few weeks ago when installing some language servers but they weren't executable, turns out I had to add ~/.local/share/npm/bin to my $PATH because that's where npm was installing everything. And now npm doesn't remove any package installed there. I've already look into the npm config (npmrc) but I don't see any option changing the install path. The only environment variable related to npm that I have is to set the user config in ~/.config/npm instead of ~/.npmrc.
I have others machines with the exact same settings and npm it's not installing packages in ~/.local/share/npm/bin/ and I'm able to uninstall packages normally.
Does anyone knows whats wrong with npm ?
npm --version 7.8.0
my config:
cache=/home/user/.cache/npm
init-module=/home/user/.config/npm/config/npm-init.js
package-lock=false
tmp=/run/user/1000/npm
Okay I noticed that if I reinstalled the packages that I couldn't remove they went into a different folder /user/bin/ with the node_modules being in /user/lib/node_modules. Before it was in ~/.local/share/npm/lib. Now with the packages were they belong I can't remove them without issues. No idea why those packages were originally installed in a different path.

How to solve 'vue-cli-service' is not recognized as an internal or external command?

I am getting an error when trying to run npm run serve. At first I installed node.js then vue as well as vue/cli.
But when I am trying to run server as -> npm run serve at that time I'm getting error like 'vue-cli-service' is not recognized as an internal or external command.
I used below codes for installation:
npm install -g vue
npm install -g #vue/cli
can someone guide me what to do to solve this issue ?
I think you are using cmd in windows.
Try deleting the node_modules folder and after that run npm i from the cmd.
Then try running npm run serve again and see if it works this time
Install vue/cli-service globally
npm install #vue/cli-service -g
This will install global npm package.
#vue/cli-service is usully installed as global, because you do not usually copy these types of packages to every project.
If the global npm package gets corrupted, it is not stored in node_modules folder, but rather in other depending on the os. Therefore removing node_modules does not help. Locations for global node_modules folders are
%USERPROFILE%\AppData\Roaming\npm\node_modules (Win10) or
/usr/local/lib/node_modules (Linux),
check this stack overflow post on how to locate global packages.
it will depend on the package manager you are using
delete node_modules
if you are using yarn run yarn or yarn install and then yarn serve
if you are using npm run npm install and then npm run serve
In my case, the package #vue/cli-service is installed in my local node_modules environment, but not my global environment, so it cannot be used as a command. I type .\node_modules\.bin\vue-cli-service serve and it works.
As it is mentioned in terminal that node_modules is missing from your project, so you can't directly use npm run serve, first you have to do npm install then do npm run serve. It will work fine
In my case I ran below commands in GitBash and it worked fine
npm install
npm run serve
If you are using cmd in windows.
deleting the node_modules folder and after that run npm istall from
the cmd.
run npm run serve and see if it works this time
In my case, I have checked the folder of node_modules was missing. I am using Windows. So I run this in cmd.
npm install
npm run serve
Then I check it in localhost like usual.
This issue mostly happens when either #vue/cli is not installed or in most cases,
#vue/cli is already installed and you are currently working on a project and when running
yarn serve or npm run serve.
Most at times, this issue is been caused by broken dependencies.
to fix this issue, simple run
yarn install or npm install
depending on your package manager.
well after trying all the solutions above and it still haven't worked for you then you probably have a stupid space in the full directory of your Vue project like in my case. so remove that that space and it will work from then on.
Remember to set the NODE_ENV=development and run npm install again
Try changing the project path to one without spaces, it worked on windows 10
I had faced the same problem in windows. Then
first I deleted the node_module. then I run npm install.
For Windows you should modify package.json to:
"scripts": {
"serve": "vue-cli-service.cmd serve",
"build": "vue-cli-service.cmd build",
"lint": "vue-cli-service.cmd lint"
}
,
I had the same issue using windows + WSL2 (Ubuntu 20.04). Looking at the logs generated after trying to run npm i I noticed that my WSL2 environment did not have python2 installed. So to solve I ran the following commands:
sudo apt-get install python2
rm -rf node_modules
npm i
npm run serve
I faced the same in Windows. Had to run npm install again. Then it worked perfectly.
Wait, what's the difference between #vue/cli and #vue/cli-service? When you install both, they show different number of packages installed. The latter solved my issue actually but everyone keeps saying install #vue/cli.
try running npm i or npm install and then proceed to run npm i vue after previous installation done. works for me
you need use "npm install" at Command Line
Before running "npm install", try running this command first:
npm set strict-ssl false
Like you, I got the error below when I ran npm run serve from the CMD command line,
'vue-cli-service' is not recognized as an internal or external
command, operable program or batch file.
I got past this familiar error by using the following command to add the npm folder to the PATH that CMD searches for executables:
path=%path%;C:\Users\<USERNAME>\AppData\Roaming\npm
where <USERNAME> is your Windows user profile directory name. Only then was I able to run the following commands successfully:
npm install
npm run serve
What solved the issue for me was renaming the directory. I had used the symbol "&" on the folder name and it seems to break things, so changing it to "and" fixed the issue.
This will probably be an incredibly niche thing, but if I help even 1 person it's fine by me.
I have a project, I can run it well on Linux, but i have the same issue on windows, I solve it this way (I hope in your case it works too):
Delete the node_modules
Install it again with npm i

HRM module stop working on the same project on which it is working earlier

Hot reload module stop working on my project because of which i have to run this command each time i make any changes.
npm run serve
This usually is npm packages problem and is often remedied by reinstallation
first remove the node_modules directory in project root
also you can clear the npm cache npm cache clean --force(this is optional)
then reinstall packages npm i

npm not defaulting local installs to ./node_modules

When I try to do a local install (eg. npm install socket.io), it's putting the module in the ~/src/node_modules/ folder. npm root reports this folder as well. I must have screwed up npm's settings during some bleary eyed late night session, but I can't figure out how to get it set back to ./node_modules as the default. Anyone know what I screwed up, and how to set it back to the default?
Update
I have tried npm config set root ./node_modules but npm root still reports ~/src/node_modules as the root. I also checked .bash_profile and no node related settings are being made in it.
A quick npm uninstall npm -g and then another install from the npm website should get your defaults back.
Normally reinstalling is a pain but with your package.json files you can get everything set back up with a quick npm link