npm install failing due to icu4c dependency - node.js

My npm install is failing with
dyld[18001]: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.69.dylib
Referenced from: <5B5BD059-AB6C-3B95-A106-6E1FD974D76D> /usr/local/Cellar/node#10/10.24.1_1/bin/node
Reason: tried: '/usr/local/opt/icu4c/lib/libicui18n.69.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/icu4c/lib/libicui18n.69.dylib' (no such file), '/usr/local/opt/icu4c/lib/libicui18n.69.dylib' (no such file), '/usr/local/lib/libicui18n.69.dylib' (no such file), '/usr/lib/libicui18n.69.dylib' (no such file, not in dyld cache), '/usr/local/Cellar/icu4c/72.1/lib/libicui18n.69.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/Cellar/icu4c/72.1/lib/libicui18n.69.dylib' (no such file), '/usr/local/Cellar/icu4c/72.1/lib/libicui18n.69.dylib' (no such file), '/usr/local/lib/libicui18n.69.dylib' (no such file), '/usr/lib/libicui18n.69.dylib' (no such file, not in dyld cache)
zsh: abort npm install
I upgraded my icu4c package to 72.1 as mentioned in some posts.
However not able to get the specific version 69 which probably node needs.
I am on node 19.6.0.
Do i need to get the 69 version of icu4c ?
Best Regards,
Saurav

It seems there was on older version of node version installed through brew.
If we run brew uninstall then the old node versions are not removed if they had been explicitly installed using the version.
Uninstalled the node version explicitly and then it works.

Related

Doesn't install NPM when I install a new Node version using NVM

Whenever I update Node with nvm, npm is no longer available.
nvm install 14.19.3 > It says it's also downloading and installing npm.
npm > Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
Looking in C:\Users\Username\AppData\Roaming\nvm\v14.19.3, the subfolder node_modules is empty. It doesn't seem to have installed npm along with nvm, even though there was no error upon nvm install 14.19.3.
From this post I understand the cause of a problem like this generally is a conflict in the environment variables of the OS (I'm using VSC on a Windows 10 machine).
But I can't find anything wrong there: PATH includes NVM_HOME and NVM_SYMLINK, which respectively point to C:\Users\Username\AppData\Roaming\nvm and C:\Program Files\nodejs.
How can I get this new version of Node to work?
I had to update my nvm for windows version (from 1.1.7 to 1.1.9).
After this I uninstalled the Node version and installed it again with the new nvm version. Now it did install NPM along with Node.
nvm use 14.20.0 (the new Node version I installed) gave an error however:
exit status 5: Access is denied.
Running the terminal / Visual Studio Code with administrator privilages solved this issue and I was able to successfully switch Node versions.
Shouldn't the NVM_SYMLINK point to %AppData%\npm or C:\Users\Username\AppData\npm?
Have you tried to: nvm install-latest-npm or nvm install --latest-npm?
Also check it out this answer as it may help.
Another solution was to just pick another Node version. I am not sure for a particular reason but I used via NVM at least 4 different version and they are all fine. Only the following version 14.17.0 seems buggy.

Node Canvas throwing error when running project

Node Canvas is not working for me on m1
When I try to run my project I get this error message:
Error: dlopen(.../node_modules/canvas/build/Release/canvas.node, 0x0001): tried: '.../node_modules/canvas/build/Release/canvas.node' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/local/lib/canvas.node' (no such file), '/usr/lib/canvas.node' (no such file)
Already did:
brew install pkg-config cairo pango libpng jpeg giflib librsvg
xcode-select --install
npm i canvas
With no errors
Not sure how to debug this as there are people with Node Canvas working on m1 laptops, please help.
The most important thing is to make sure your Node executable has been compiled for Apple Silicon, meaning there's a pre-built binary for darwin-arm64. You can see which versions have which binaries here (the following page has the binaries for Node version 16.13.1): https://nodejs.org/download/release/v16.13.1/.
Node v14 has no pre-built binaries for darwin-arm64 (see https://github.com/nodejs/node/issues/36161), because it can't be compiled natively to Apple Silicon.
I use volta (https://volta.sh/) to manage my Node versions, so if you install Node v16 with volta install node#16 and then run npm i canvas, you should get a correctly compiled canvas.node file.
If that fails, go to node_modules/canvas and run npm install --build-from-source, which will compile the C++ addon and output the corect canvas.node.
You can check this by running:
file node_modules/canvas/build/Release/canvas.node
# outputs: node_modules/canvas/build/Release/canvas.node: Mach-O 64-bit bundle arm64
If it says arm64 at the end, then you're good to go. If it still says x86_64, then something went wrong.
I use npm install --build-from-source. It work!
But there are new mistakes
dlopen(.../node_modules/canvas/build/Release/canvas.node, 0x0001): symbol not found in flat namespace '_cairo_fill'

Sorry, there's a problem with nodist. When trying to initilise a new npm project

I am following the following guide from GitHub Here but when I enter npm init I keep getting the error:
Sorry, there's a problem with nodist. Couldn't resolve node version
spec %s: %s 11.13.0 Couldn't find any matching version
I have followed the previous steps and set the version to v10.15.3, but the error keeps appearing every time I use nvm. I have also set the version to v11.13.0, as this is what the error is requesting, but I still get the same result. Installed versions include: 11.13.0, 10.16.0, 10.15.3, 8.11.2, 0.12.0
Any help with this would be much appreciated!
There are several reasons which can cause this problem:
If due to some reasons like poor internet connection your node or npm versions you have downloaded are corrupted. In this case you need to remove the files .npm-version-global and .node-version-global as well as empty the folders v, v-64 and npmv within the installation of the Nodist folder.
You have a local version of the node specified in .node-version file in the root directory of your project. In this case you need to install that version by nodist local XXX where XXX is the version of the node in .node-version file.
In my case, the problem was that I had a node version specified in my code repo that didn't match the node version installed on my machine. I needed the updated node version on my machine, so
I opened file explorer to the root of my repo.
I opened .node-version and edited the version number to the updated version I needed.
npm cache clean --force to start with a fresh cache. (Note: Others have said that npm cache clean --force is outdated, but this command worked for both my teammate and for me using npm version 6.9.0.)
npm install to reinstall my node modules.
npm run build and I had a clean build. Yay!
For Node 18 and npm 8.19.1, I found the advice at https://github.com/nullivex/nodist/issues/252#issuecomment-1170897428 useful.
I was getting cb.apply errors, and problems with #npmcli/arborist and libnpmfund, but I created those two links from the list.
I was using npx. This installs an old (v 5.8) version of npm inside its node_modules. That npm contains graceful-fs inside its node_modules. The cb.apply error was coming frome graceful-fs's polyfill.js.
I installed the latest version of graceful-fs, and copied the newer polyfill.js into the abovementioned (child of npm's) graceful-fs. This seemed to fix the problem for me.

NPM global packages not available on Ubuntu

MY SITUATION
I have installed version Node v6.2.0 using n on Ubuntu 14.04. It's located under path /usr/local/n/versions/node/6.2.0 (by using npm prefix -g).
My global packages installs in that directory under lib/node_modules but I can't use that packages from command line globally.
NOTE
Earlier I was using older version Nodejs 5 installed different way. And packages installed globally with that version of Node are available now, but not new ones which I installing now.
MY QUESTION
Is there a trick or something to point node_modules directory from which its packages could be used globally?
Your global package binaries should be available here:
/usr/local/n/versions/node/{NODE VERSION}/bin
Add it to your path (in .bashrc or .bashprofile or .zshrc):
NPM_GLOBALS=/usr/local/n/versions/node/{NODE VERSION}/bin
PATH=$NPM_GLOBALS:$PATH
Then restart your console or just run source ~/.bashrc
Also, if you're working with multiple versions of node, I highly recommend nvm for installing and managing them.
I simply added export PATH=~/.npm-global/bin:$PATH to my .zshrc file.

npm comes with node now. What does this mean?

Node noob here.
I had previously installed both npm and node separately.
Apparently, npm comes with node now. (link)
To my newbie mind, this means my previous dual installation is old and ugly. 1 binary > 2 binaries. So i uninstalled both.
Then I installed the latest node following the procedure. (i am running eOS)
Terminal
user#box:-$ which node
/usr/bin/node
user#box:-$ node -v
v0.10.22
user#box:-$ which npm
user#box:-$ npm -v
bash: /usr/bin/npm: No such file or directory
I can always run:
curl https://npmjs.org/install.sh | sh
but that seems to indicate that npm is actually NOT included in node.
When they say they are included do they just mean the code is in the same repo, but the binaries are still different?
Final question I have /usr/bin/node as well as /usr/bin/nodejs
can i delete one of these? im not sure when/where i picked up a second copy.
Yes, the nodejs package includes both node and npm executables. The code for each has its own repo, but when packaged both are included.
npm source: https://github.com/isaacs/npm
node source: https://github.com/joyent/node
When you install that .deb file from the PPA, you should get both /usr/bin/nodejs and /usr/bin/npm and 2 symlinks at /usr/bin/node (which points to) /etc/alternatives/node (which points to /usr/bin/nodejs).
If any of this isn't true, your install didn't fully succeed, most likely due to conflicting files you left around from your manual install. I would suggest uninstalling the .deb then making sure there are no stale files left from your manual install and then installing again.
Only node.js packages comes with npm. so if you are installing using an .msi, .exe, .dmg .pkg, .deb or using a package installer like apt-get, yum or brew, then you'll have both node and npm.
However,npm is not part of the node core. if you are installing node and using a method where you are using ./configure or make install || make link, then npm will not be installed, and will need to be compiled using the same type of installation, and node will have to be placed on your path.
If you used git, or unzipped node and you can see a configure script, then you will also need to acquire npm.
I've had issues (mostly on Mac) with npm ending up in directories that aren't in the terminal PATH. If you can figure out where npm is located, you can just add it to your path with something like:
export PATH=$PATH:/path/to/npm
I think (I'm not on a mac so I can't check at the moment) that it sometimes gets put in /usr/local/share/. But at any rate, the problem is likely NOT that npm isn't installed, but that it's installed somewhere you're not expecting.
Few months ago i had started learning the react so all this stuff i needed to install my laptop that had the ubuntu operating system.
What i did -- First i installed the node and without knowing that it came up with the npm package. I installed the npm package again.. but there was no conflict at all.
But after exploring all these things that nodejs have npm package. So i uninstalled the npm package due to concern about memory usage..
And Now everything is working fine....

Resources