Having trouble installing npm on mac M1 - node.js

npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN deprecated bcrypt#4.0.1: versions < v5.0.0 do not handle NUL in passwords properly
npm ERR! code 1
npm ERR! path /Users/nikhil/Desktop/admin/myprivatescout-master/node_modules/node
npm ERR! command failed
npm ERR! command sh -c node installArchSpecificPackage
npm ERR! npm ERR! code ETARGET
npm ERR! npm ERR! notarget No matching version found for node-darwin-arm64#16.6.1.
npm ERR! npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! npm ERR! notarget a package version that doesn't exist.
npm ERR!
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR! /Users/nikhil/.npm/_logs/2021-08-23T17_20_39_011Z-debug.log
npm ERR! node:internal/modules/cjs/loader:936
npm ERR! throw err;
npm ERR! ^
npm ERR!
npm ERR! Error: Cannot find module 'node-darwin-arm64/package.json'
npm ERR! Require stack:
npm ERR! - /Users/nikhil/Desktop/admin/myprivatescout-master/node_modules/node/installArchSpecificPackage.js
npm ERR! at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
npm ERR! at Function.resolve (node:internal/modules/cjs/helpers:100:19)
npm ERR! at ChildProcess.<anonymous> (/Users/nikhil/Desktop/admin/myprivatescout-master/node_modules/node-bin-setup/index.js:18:27)
npm ERR! at ChildProcess.emit (node:events:394:28)
npm ERR! at maybeClose (node:internal/child_process:1067:16)
npm ERR! at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5) {
npm ERR! code: 'MODULE_NOT_FOUND',
npm ERR! requireStack: [
npm ERR! '/Users/nikhil/Desktop/admin/myprivatescout-master/node_modules/node/installArchSpecificPackage.js'
npm ERR! ]
npm ERR! }
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/nikhil/.npm/_logs/2021-08-23T17_20_39_074Z-debug.log
I am unable to install any package in my project repository on my mac M1, already removed node_modules and package-lock.json and tried npm i after that.
tried running npm i, npm i for individual packages but couldn't fix it,
Also tried installing with yarn but I am facing the same issue.

Add the architecture to the node:
$ nvm uninstall 14
$ arch -x86_64 zsh
$ nvm install 14
$ nvm alias default 14

The solution provided by Nikhil is a good start. However, this is more complete and applicable in more situations:
First, install nvm (Node version manager):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
Then, run the following command:
arch -x86_64 zsh

We had a dev with this problem, a M1 laptop bought new in December 2021. The solution by ralphjsmit got us part of the way.
We're using Nodejs v16.13.1. After running arch -x86_64 zsh the npm install still failed (Error: Cannot find module 'node-darwin-arm64/package.json').
arch returned i386.
The key for us was to re-install Nodejs (via nvm, nvm use v16.5.0 && nvm uninstall v16.13.1 && nvm install v16.13.1)
If I were to summarize all the steps we ran, they'd be
> node -v
v16.13.1
> node -p process.arch
arm64
> arch -x86_64 zsh
> nvm use 16.5.0 && nvm uninstall v16.13.1 && nvm install v16.13.1
nvm use 16.5.0 && nvm uninstall v16.13.1 && nvm install v16.13.1
Now using node v16.5.0 (npm v7.19.1)
Uninstalled node v16.13.1
Downloading and installing node v16.13.1...
...
# output here, I am not on an M1 machine, but it mentions x64 in the name of the node binary file
...
Now using node v16.13.1 (npm v8.1.2)
> npm install

It seems that reinstalling an older version of NodeJS (& NPM) helped me.
Try version 14.18.3 from here.

Make sure you do not have a specified node version in package.json.

arch -arm64 npm i worked for me!

Related

Node 8.0 install, but npm stuck on old version

Installed node version v8 on windows 10. It says it comes delivered with npm 5....
But it's stuck on 3.5.3
λ npm i -g npm
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "npm" "i" "-g" "npm"
npm ERR! node v8.0.0
**npm ERR! npm v3.5.3**
**npm ERR! code MODULE_NOT_FOUND**
**npm ERR! Cannot find module 'internal/fs'**
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\user\npm-debug.log
What i've done:
Uninstall node and reinstall it
Install a different version of node (7.7.0) and see if it updated npm
used npm clean cache -f
And none of these things worked...
So any ideas?
I had the same problem and had to run
npm install npm#latest -g
from the command line. I was told node and npm versions will be different.
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

Getting Error when trying to install browser-sync ubuntu

Node is Updated to latest stable version v7.4.0
This is the error message I get when trying to install browser-sync:
sudo npm install -g browser-sync
'npm ERR! Linux 4.4.0-59-generic npm ERR! argv "/usr/local/bin/node"
"/usr/local/bin/npm" "install" "-g" "browser-sync" npm ERR! node
v7.4.0 npm ERR! npm v4.0.5 npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'internal/fs' npm ERR! npm ERR! If you
need help, you may report this error at: npm ERR!
https://github.com/npm/npm/issues
npm ERR! Please include the following file with any support request:
npm ERR! /home/pedro/npm-debug.log '
This problem occurs when you are installing a old module(as written in your package.json) but it is not available on git due to update in their version.
for solving this issue.
1.Need to install the project’s local dependencies (that’s where it’s looking for browser-sync). To do that,
2.cd into the project directory and run npm install.
3.You can also try npm i browser-sync --save
You're going to need to upgrade npm also (currently npm#next – npm -g install npm#next if you have it installed globally.
I have Solved the issue:
NPM Module was not supported by node v7:
So I downgraded to node v6.4.0 and it allowed me install browser-sync with no problems!
sudo npm cache clean -f
sudo npm install -g n
sudo n 6.9.5

npm install - Error: No compatible version found: cherrio#'^0.17.0' - manual install then loop of package install

I'm trying to get into a legacy program, which doesn't have any other developers remaining that worked on it over a year ago.
The readme says to install via npm install. When I ran that, it complained about the version of node and suggested node 0.8.x. Based on that I used nvm install 0.8.9 then did nvm use 0.8.9.
When I run npm install, I now get:
npm ERR! Error: No compatible version found: cheerio#'^0.17.0'
npm ERR! Valid install targets:
npm ERR! ["0.0.1","0.0.2","0.0.3","0.0.4","0.1.1","0.1.2","0.1.3","0.1.4","0.1.5","0.2.0","0.2.1","0.2.2","0.3.0","0.3.1","0.3.2","0.4.0","0.4.1","0.4.2","0.5.0","0.5.1","0.5.2","0.6.0","0.6.1","0.6.2","0.7.0","0.8.0","0.8.1","0.8.2","0.8.3","0.9.0","0.9.1","0.9.2","0.10.0","0.10.1","0.10.2","0.10.3","0.10.4","0.10.5","0.10.6","0.10.7","0.10.8","0.11.0","0.12.0","0.12.1","0.12.2","0.12.3","0.12.4","0.13.0","0.13.1","0.14.0","0.15.0","0.16.0","0.17.0","0.18.0","0.19.0","0.20.0"]
npm ERR! at installTargetsError (~/.nvm/v0.8.9/lib/node_modules/npm/lib/cache.js:553:10)
npm ERR! at ~/.nvm/v0.8.9/lib/node_modules/npm/lib/cache.js:477:15
npm ERR! at saved (~/.nvm/v0.8.9/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:138:7)
npm ERR! at ~/.nvm/v0.8.9/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:220:7
npm ERR! at Object.oncomplete (fs.js:297:15)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR! System Darwin 14.5.0
npm ERR! command "~/.nvm/v0.8.9/bin/node" "~/.nvm/v0.8.9/bin/npm" "install"
npm ERR! cwd ~/workspace/path/to/project
npm ERR! node -v v0.8.9
npm ERR! npm -v 1.1.61
What bothers me is the fact that it references ^0.17.0 and from reading, it sounds like that should support any 0.x.y version that is 0.17.0 or greater. Since 0.17.0, 0.18.0, 0.19.0 and 0.20.0 are in the list, I would assume that things should be just peachy.
If I do node install cheerio#0.17.0 then it seems to work, I then do another npm install and get a new package error like the above, I then manually do the version and it seems to loop back to the cheerio package.
Thoughts on what I'm missing?
Did you get '^0.17.0' from json? To work in cmd just remove apostrophe's.
npm install cheerio#^0.17.0

Unable to install node modules

I've installed node on my debian squeeze dedicated server, but i can't install new mode module
ex : npm install async
Results :
root#....# npm install async
npm http GET https://registry.npmjs.org/async
npm ERR! Error: failed to fetch from registry: async
npm ERR! at /usr/local/lib/node_modules/npm/lib/utils/npm-registry-client/get.js:139:12
npm ERR! at cb (/usr/local/lib/node_modules/npm/lib/utils/npm-registry-client/request.js:32:9)
npm ERR! at Request._callback (/usr/local/lib/node_modules/npm/lib/utils/npm-registry-client/request.js:137:18)
npm ERR! at Request.callback (/usr/local/lib/node_modules/npm/node_modules/request/main.js:109:22)
npm ERR! at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/main.js:198:58)
npm ERR! at Request.emit (events.js:88:20)
npm ERR! at ClientRequest.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/main.js:356:14)
npm ERR! at ClientRequest.emit (events.js:67:17)
npm ERR! at HTTPParser.onIncoming (http.js:1238:11)
npm ERR! at HTTPParser.onHeadersComplete (http.js:102:31)
npm ERR! You may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR!
npm ERR! System Linux 3.2.13-xxxx-std-ipv6-64
npm ERR! command "node" "/usr/local/bin/npm" "install" "async"
npm ERR! cwd /root
npm ERR! node -v v0.6.8
npm ERR! npm -v 1.1.0-2
npm ERR! message failed to fetch from registry: async
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /root/npm-debug.log
npm not ok
UPDATE (1/11/2015):
I now use NVM to manage my node/npm installation on both Linux and Unix. It's super simple; just follow these steps.
Install NVM.
$ curl https://raw.githubusercontent.com/creationix/nvm/v0.22.1/install.sh | bash
Use NVM to install the latest stable version of node and NPM.
$ nvm install stable
Tell NVM to use the stable version as the default version in future bash instances.
$ nvm alias default stable
Now you're all set with node & NPM. NVM even gets rid of the permissions issues with NPM global modules on Ubuntu, which normally requires you to chown or sudo and causes all sorts of frustration. You can use NVM to install different versions of node/NPM side by side as well. You can switch between installed versions with nvm use {version}, as long as you've done nvm install {version} already.
I think you may be running a really old version of node & npm. I see that node is v0.6.8 and npm is 1.1.0-2 when the current versions are 0.10.26 & 1.4.6 respectively. I'd try upgrading your node and npm installs and then try installing modules again and see if that fixes it for you.
Head over to http://nodejs.org and click the big green button in order to get the node installer. It will install both node & npm together.
Note: It's sometimes better not to install node/npm from a package manager unless you're confident the version listed in the package manager is the latest version. It's important to keep npm up to date. Npm even updates itself along with all your global node modules when you run npm update -g.

Not able to install bower using npm on Ubuntu 13.04

I am not able to install bower.
Steps carried out :
Installed node.js (current stable version v0.10.12)
Installed npm using apt-get (v1.1.4)
Tried installing bower using :
npm install bower
I get the possible node.js incompatible error.
The weird thing is that the error log indicates that the script went to the node directory & tried node -v to get an old version of node.js (v0.6.19) though when I do so manually I get v.0.10.12.
Error Log :
npm http GET https://registry.npmjs.org/bower
npm ERR! Error: No compatible version found: bower
npm ERR! No valid targets found.
npm ERR! Perhaps not compatible with your version of node?
npm ERR! at installTargetsError (/usr/share/npm/lib/cache.js:488:10)
npm ERR! at next_ (/usr/share/npm/lib/cache.js:438:17)
npm ERR! at next (/usr/share/npm/lib/cache.js:415:44)
npm ERR! at /usr/share/npm/lib/cache.js:408:5
npm ERR! at saved (/usr/share/npm/lib/utils/npm-registry-client/get.js:147:7)
npm ERR! at Object.oncomplete (/usr/lib/nodejs/graceful-fs.js:230:7)
npm ERR! You may report this log at:
npm ERR! <http://bugs.debian.org/npm>
npm ERR! or use
npm ERR! reportbug --attach /usr/share/node-v0.10.12/npm-debug.log npm
npm ERR!
npm ERR! System Linux 3.8.0-25-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "bower"
npm ERR! cwd /usr/share/node-v0.10.12
npm ERR! node -v v0.6.19
npm ERR! npm -v 1.1.4
npm ERR! message No compatible version found: bower
npm ERR! message No valid targets found.
npm ERR! message Perhaps not compatible with your version of node?
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /usr/share/node-v0.10.12/npm-debug.log
npm not ok
Need a way to install bower. Any ideas ?
I had the same issue on ubuntu 12.04 here is how I fixed it:
As GabLeRoux mentioned, Node version manager requires curl package to be installed and therefore you might need to install curl before:
sudo apt-get install curl -y
1) Clear NPM's cache:
sudo npm cache clean -f
2) Install a little helper called 'n' (node version manager)
sudo npm install -g n
3) Install latest stable NodeJS version
sudo n stable
4) Install Bower again
sudo npm install -g bower
Try this, because you must install it as superuser:
sudo npm install bower
You must type in your su password.
I recommend using the linux binary from nodejs.org. Available for both 32-bit and 64-bit versions and installs with NPM:
http://nodejs.org/download/
This should prevent any node/npm version conflicts.
For Cent OS users -
I first had to update NPM to get around this, and was getting errno 34 for bower on CentOS 7
sudo npm install -g npm
sudo npm install -g bower
If you get sudo npm command not found, you can edit /etc/sudoers to include npm bin path
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin

Resources