can't install module 'merge-descriptors' - node.js

I'm new to node.js.
I'm using WebStorm. I work on Windows.
I configured my app to run on node.js and when I try to run it I get this error:"Cannot find module 'merge-descriptors'".
I followed these post trying to solve it: How do I resolve "Cannot find module" error using Node.js?,
module.js:338 throw err in node.js
I ran "del /s /q node_modules" (parallel to "rm -rf node_modules").
Now I'm trying to run "npm install -g" and I'm getting this error:
See screen shot below
I've tried to understand it and to look for information about it in the net to no avail.
Any help will be profoundly appreciated!

I had similar issue installing the module, I tried npm install or npm update but my network would timeout. However what I did is very simple:
npm install merge-descriptors --save

When installing the dependencies for a package you should be using npm install and not using the -g flag.
The g flag, or global is used when installing a package globally, which places them in a direct location that is not accessible by the project.
See https://docs.npmjs.com/files/folders

The specific error you're seeing is that the logged in user doesn't have permission to write to the install directory. This can be overcome with sudo command, ex., sudo npm install. But as others have indicated, if you have to do this then something about your app's configuration could be wrong.

Related

NPM get prefix issues

I am having issues with the npm. (on MAC)
I installed node and npm normally, but couldn't run:
$npm install -g angular-cli
it says unhandled rejection error, EACCESS: ...
and none of the solutions I found on the web couldn't help me.
I tried to reinstall node and npm multiple times, didn't help.
Then I tried to make an ionic project through the terminal, unsuccessfully. Similar issue EACCESS: permission denied...
And now I kind of messed up something with:
$npm config get prefix and $npm config set prefix
whenever I try to run some npm command I get a bunch of lines:
Eaccess, cannot read property, etc...
Does anybody know how can I solve this?
Is there a way to completely remove nodejs and npm and then to install it from scratch.
The traditional way and using homebrew didn't help me.
Try: nvm uninstall {version of node you are using}
To get the version do: npm -version

Node MODULE_NOT_FOUND

I just upgraded to node version 9.0.0 and am now getting this error in the command line when trying to use npm install
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'internal/util/types'
I'm using:
OSX 10.10.5
Node version 9.0.0
NPM version 5.5.1
Extra information: I am also trying to do this with a Laravel 5.5 project. This is how I update my version of node: How do I update Node.js?
run
rm -rf /usr/local/lib/node_modules/npm
and then re-install Node.js will work in most cases
Leaving this here for anyone using the n nodejs version manager:
$ n 6.12.0 # Go back to a stable release
$ npm install -g npm#latest # Update npm to latest
$ n lts # Get 8.9.1
$ npm install #Should work now.
The MODULE_NOT_FOUND error seems to happen when changing between node versions and some files are possibly still being cached. I am not sure exactly but the above sequence of commands work for me.
When I first got this, I solved just running "npm install" again to make sure everything was installed.
I got similar error also on Windows 8 after I have just upgraded node js. First: how I ran into the issue then the solution that worked for me.
How I ran to the issue:
When I did npm --version and node --version I discovered that I wass running npm v3.x and node 5.x. So I went to nodejs.org site from where I downloaded node-v8.11.3-x64.msi. After installing the msi package I confirmed that my nodejs version was now v8.11.3 via node --version command.
Then, when I ran "npm install http-server" (w/o the quotes) that's when I got the issue:
npm ERR!
node v8.11.3
npm ERR! npm v3.5.3
npm ERR! code MODULE_NOT_FOUND
My resolution:
I did some research including on the internet and found out that the npm version pointed to in my path was the one in my roaming profile C:\Users[myname.hostname]\AppData\Roaming\npm. In other words, the npm being used is not the one in the updated package I have just installed which is located in C:\Program Files\nodejs.
The resolution was to delete npm and npm-cache in the roaming folder. Note, I used cygwin as I was not able to delete these folders via Windows cmd prompt. With cygwin, I navigated to
cd "C:\Users[myname.hostname]\AppData\Roaming"
Then I removed the aforementioned folders like so
rm -rf npm-cache
rm -rf npm
After that, I opened a new Windows cmd prompt and was able to now successfully install http-server like so:
npm install http-server
Hope this works for you.
For me it was package installation issue, so I just write,
npm i or npm install in the root of the application.
to open the terminal in the root of the application, if you're using VS-code right click on the package.json and click on Open in integrated terminal.
I founded this problem too, so I found that I have imported wrong module instead of express module I had imported router module after I had replaced this two my code work as well
If all the above solutions doesn’t work check for any blank spaces in your folder/file where you copied the path
Make sure you are inside the project folder.
Rename the folder "node_modules" to any other name (for example: node_modules_old).
Run command: "npm i" (the command will build new the folder node_modules).
Try running your program again.
If the problem is resolved and your program is running correct, delete the old folder node_modules.
If you are using libraries make sure to install everything with npm or yarn before starting. And in cases of you files if you are going to use them make sure to do the export.module thing everytime.
If you are working with Local modules then don't have node_modules. All things go well in a easy way.
But if you want to work with both local and node_modules then use
.mjs (extension) - For modules
.cjs (extension) - For common scripts which you want to run with node
in which you can use require statements like
var http = require('http');
var fs = require('fs');
but if using .js extension then use
import http from "http"
import fs from "fs"
And also your package.json for type
Haa well, I have spent two days on this and have done everything I can to fix this issue even tried resetting the system but none of them reloved the issue.
And accidentally found out what was causing this issue, it is because of & in my parent folder name. File hierarchy R&D>remix>blog, When I was trying to run the blog server it was throwing module not found, require stack error.
code: ←[32m'MODULE_NOT_FOUND'←[39m,
requireStack: []
Solution: I have changed the parent folder name to RnD and it fixed the issue. If the file name contains any special characters(even parent folders) try updating it. In my case, it is &
The MODULE_NOT_FOUND error happened to me and even running npm install the error persisted.
Try to do this
For me, what worked was deleting the node_modules folder
rm -r -f node_modules/
After that, run the command to install the package.json dependencies
npm install
What happened to me was that when I ran npm install for the first time I had a very low internet connection and therefore I believe that the packages from package.json were not downloaded correctly and due to that the MODULE_NOT_FOUND error occurred. The funny thing is that just running the npm install command has no effect because it understands that the package is already there but it isn't. Similar as a corrupted data. In my case the npm update was without effect too.
If when you are using React And getting this error message. You can use this ,
NPM
npm install #reduxjs/toolkit
Yarn
yarn add #reduxjs/toolkit

Angular - ng: command not found

I'm trying to learn Angular and my knowledge in terminal is beginner. After I installed Angular and then type ng new my-project. I get the response ng: command not found. I've seen other posts that had this problem and I've uninstalled and reinstalled npm and ng.
The last step I took was npm install -g #angular/cli#latest then ng new my-project.
Then I get ng: command not found.
Guess You are running on Windows
(To make #jowey's answer more straightforward).
Install Angular normally from your bash $ npm install -g #angular/cli#latest
Next is to rearrange the PATHS to
NPM
Nodejs
Angular CLI
in System Environment Variables, the picture below shows the arrangement.
I had that same problem and just solved it.
make sure you have node installed.
after running
npm i -g #angular/cli
when installation is finished, try re-opening your git bash or whatever you're using or open it in a new folder. boom. it worked for me
The error may occur if the NodeJs is installed incorrectly or not installed at all.
The proper way to fix that is to install/reinstall it the right way (check their official website for that), but if you're searching for a quick solution, you can try to install Angular CLI globally:
npm install -g #angular/cli
If it doesn't work and you are in a hurry, use sudo:
sudo npm install -g #angular/cli
Don't forget to reopen your terminal window.
For MacOS
Sometimes the ng command does not get established as a link in /usr/local/bin. I fixed the problem by adding it manually:
ln -s /usr/local/Cellar/node/10.10.0/lib/node_modules/angular-cli/bin/ng /usr/local/bin/ng
It may has not helped OP, but it solved my problem. This answer is to help others who have not tried the command mentioned in OP's question.
Just use npm install -g #angular/cli#latest. It did the trick for me.
If you have already installed #angular/cli
Then you only need to link it to npm using npm link #angular/cli
Otherwise first install angular by npm install #angular/cli and then link.
if you install npm correctly in this way:
npm install -g #angular/cli#latest
and still have that problem, it maybe because you run the command in shell and not in cmd (you need to run command in cmd), check this out and maybe it helps...
If you are working on Windows then do the following:
From this directory:
C:\Users\ [your username] \AppData\Roaming , delete NPM folder then install Angular using this command npm install -g #angular/cli
*Windows only*
The clue is to arrange the entries in the path variable right.
As the NPM wiki tells us:
Because the installer puts C:\Program Files (x86)\nodejs before C:\Users<username>\AppData\Roaming\npm on your PATH, it will always use version of npm installed with node instead of the version of npm you installed using npm -g install npm#.
So your path variable will look something like:
C:\<path-to-node-installation>;%appdata%\npm;
Now you have to possibilities:
Swap the two entries so it will look like
…;%appdata%\npm;C:\<path-to-node-installation>;…
This will load the npm version installed with npm (and not with node) and with it the installed Agnular CLI version.
If you (for whatever reason) like to use the npm version bundled with node, add the direct path to your global Angualr CLI version. After this your path variable should look like this:
…;C:\Users\<username>\AppData\Roaming\npm\node_modules\#angular\cli;C:\<path-to-node-installation>;%appdata%\npm;…
or
…;%appdata%\npm\node_modules\#angular\cli;C:\<path-to-node-installation>;%appdata%\npm;…
for the short form.
This worked for me since a while now.
Before wasting lots of time in installing and uninstalling, read this.
If you already installed angular before and found this issue, may be it is the reason that you installed angular before with running terminal as Administrator and now trying this command without administrator mode or vice versa. There is a difference in these two.
If you installed angular without administrator mode you can only use angular commands such as ng without administrator mode. Similarly,
If you installed angular with administrator mode you can use angular commands such as ng in administrator mode only.
100% working solution
1) rm -rf /usr/local/lib/node_modules
2)brew uninstall node
3)echo prefix=~/.npm-packages >> ~/.npmrc
4)brew install node
5) npm install -g #angular/cli
Finally and most importantly
6) export PATH="$HOME/.npm-packages/bin:$PATH"
Also if any editor still shown err than write
7) point over there .
100% working
Windows 10 Only
If you are using Git Bash and also you are sure that you have done all steps that are listed above, still getting an error like this, run following command:
alias ng="C:/Users/<your-username>/AppData/Roaming/npm/node_modules/#angular/cli/bin/ng"
then run ng -v
Finally, it works if you see the version of Angular-CLI
I had the same issue in Windows. I could solve it by running the ng command with npm
ng g c test
Error : C:\Users\user\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found
Solution :
$ npm run ng g c test
Other solution worked for me to use Windows PowerShell or command prompt instead of bash shell
Most of the time developers install just Node.js and start working on development. This issue related angular cli dependency on your development environment.
You can fix this with command
npm install -g #angular/cli
First of all check by running
npm config get prefix
It should return some thing like (C:\Users\acer\AppData\Roaming\npm)
if it does not return it.
run npm config delete prefix
then run npm install -g #angular/cli#latest
And check by running ng --version
It has solved my problem. Hope it will help you.
**
if you have npm, install run the command
npm install -g #angular/cli
then bind your ng using this:
cd
alias ng=".npm-global/bin/ng"
Follow the Pictures for more help.
Removing NODE and using NVM instead fixed a lot of issues.
removing Node from your system
install NVM from here https://github.com/creationix/nvm
Install Node via NVM: nvm install
stable run npm install -g angular-cli
LINK
Step 1 : Delete "npm" folder from the following path
C:\Users\YourUserName\AppData\Roaming
Step 2 : Once you have the "npm" folder deleted, uninstall Node.Js.
Step 3 : Reinstall Node.JS
Step 4 : Install Angular CLI Using this command npm install -g #angular/cli#latest
Step 5: Now try : ng --version or ng -v
I had a lot of issues installing it on a mac with all the permission errors
Finally the following line solve the issue.
sudo npm i -g #angular/cli
>> npm uninstall -g angular-cli
>> npm uninstall -g #angular/cli
>> npm cache clean
Restart you machine
then >> npm install -g #angular/cli#latest
set Path : C:\Users\admin\AppData\Roaming\npm\node_modules#angular\cli
Hope you never get 'ng' not found
I tried this and everything worked by changing the npm directory.
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
source ~/.profile
npm install -g jshint
ng --version
You can install npx to use Angular CLI installed in your directory:
npm install -g npx
npx ng serve
You must know the full path of your angular installation.
For example: C:\Users\\AppData\Roaming\npm\node_modules#angular\cli\bin\ng .
Type in cmd, powershell or bash
alias ng="C:\Users\<your username>\AppData\Roaming\npm\node_modules\#angular\cli\bin\ng"
In my case
OS Version: Ubuntu 18.04.4 LTS
Node version v12.16.0
Remove ng from /usr/local/bin by using below command.
sudo rm -r ng
After that, installed ng by using command mentioned below.
sudo npm install -g #angular/cli
For Linux user
$ alias ng="/home/jones/node_modules/#angular/cli/bin/ng"
then check angular/cli version
ng --version
enter image description here
alias ng="C:/Users/<user_name>/AppData/Roaming/npm/node_modules/#angular/cli/bin/ng".. This did work..
Happy Coding :)
I guess everyone figured this out years ago but me. simple ng stopped working when I updated node. I tried all the previous suggestions in this thread to no avail but this is my solution. the command npm ng works but darn it I want just ng to work. So
I created a bat filed named ng.bat with this content
npm ng %*
either put ng.bat in a directory recognized by path or add a new path in This Computer / Properties / Advanced System Settings / Environment Variables/ System Variables / Path . For instance I added C:\Shortcuts to path.
EDIT the above answer is not THE REAL SOLUTION. What npm need is to find the npm-cli.js which is located in the npm bin directory. If a path is not set to bin then not work. I just copied npm-cli.js and put it in the npm directoy which has a path set to it.
Windows oriented:
If you're chasing an "update node/angular and I wiped my AppData
folder and now the world hates me stream of errors", then this may help.
Clear out Environment Variable settings for Node/npm/#angular/cli (They don't help)
Install Node.JS/npm from https://nodejs.org/en/ (Remember where you install it)
Confirm the location npm is [currently] running from:
npm config get prefix
Realize that is not where you just install new/fresh Node.
Update npm global pointer (which is not an environment variable)
npm config set prefix "C:\Program Files\nodejs"
Reinstall Angular
npm install -g #angular/cli#latest
Check angular install
ng --version
Hopefully this helps someone. Sorry, you'll have to reinstall any other interesting packages.
I'll add this as "yet another option" which worked for me when none of the other options worked( on windows ).
You can run the angular binary via its full path name.
node C:\Users\user\node_modules#angular\cli\bin\ng.js --version
Oddly enough, adding these paths to my env didn't work...for some reason windows opened editor to edit ng.js file instead of running it.
For me the issue was something with node. Version was very wrong somehow.
Uninstalled node from "Add or remove programs" and then re-installed it using the file from their website.

Can install but can't run npm packages

I'm having trouble with my node.js/npm setup,
I freshly installed it via the website and it worked fine.
It told me to make sure /usr/local/bin/npm has to be in my path and when I run
echo $PATH it is in there, so it should be fine.
I can now install packages (tested with npm i webpack -save-dev) the installation works as expected, without any errors.
But when i run webpack all It is giving back is command not found has anyone experienced
something like this before?
I believe what you are looking for is a global package install.
Try using
npm i -g webpack
You can get help on install with
npm help i
Did you install node v8/npm v5?
In that case, it seems there's an open big-bug ticket on the npm repository.

npm node_modules command not found on ubuntu

I've got a problem starting npm modules f.e. ionic, cordova, protractor. When I write something f.e.like:
ionic serve
It response with:
zsh: command not found: ionic
I installed these modules globally npm install -g ionic and locally npm install ionic, but the output is still the same. Also I tried to run them locally in directory ./node_modules/.bin/ again the same result. Another thing, that I've tried to change path of installation like here Cannot run ionic. receives "No command 'ionic' found", but didn't get the needed result. I still think, that the reason is in path, that npm installs modules, in my case it's ~/npm/bin. Thanks in advance.
Try using bash and running the same command.

Resources