How to install Node 14 on a M2 Chip Apple Macbook Air? - node.js

I need to work on a project that uses Node v14.17.3. In my previous Macbook with intel chip I had node 16 but in this particular project I ran npm install node#14.17.3 and everything worked fine.
The project has the version specified on package.json file:
"engines": {
"node": "v14.17.3"
},
When I try to install node 14 on the project using my M2 Chip Macbook I get the following error:
command sh -c node installArchSpecificPackage
npm ERR! npm ERR! code ETARGET
npm ERR! npm ERR! notarget No matching version found for node-darwin-arm64#14.17.3.
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/enzo/.npm/_logs/2023-02-04T02_37_49_054Z-debug-0.log
npm ERR! node:internal/modules/cjs/loader:1050
npm ERR! throw err;
npm ERR! ^
npm ERR!
npm ERR! Error: Cannot find module 'node-bin-darwin-arm64/package.json'
npm ERR! Require stack:
npm ERR! - /Users/enzo/Documents/Project/frontend/node_modules/node/installArchSpecificPackage.js
npm ERR! at Module._resolveFilename (node:internal/modules/cjs/loader:1047:15)
npm ERR! at Function.resolve (node:internal/modules/cjs/helpers:109:19)
npm ERR! at ChildProcess.<anonymous> (/Users/enzo/Documents/TeCambio/frontend/node_modules/node-bin-setup/index.js:19:27)
npm ERR! at ChildProcess.emit (node:events:513:28)
npm ERR! at maybeClose (node:internal/child_process:1091:16)
npm ERR! at ChildProcess._handle.onexit (node:internal/child_process:302:5) {
npm ERR! code: 'MODULE_NOT_FOUND',
npm ERR! requireStack: [
npm ERR! '/Users/enzo/Documents/Project/frontend/node_modules/node/installArchSpecificPackage.js'
npm ERR! ]
npm ERR! }
npm ERR!
npm ERR! Node.js v18.14.0
Is there any solution/workaround for this issue? I was thinking about installing Rosseta and NVM but I'd rather do this with some better solution. Thanks in advance!

I could make it work:
For Apple Computers with M1 and M2 Chip you'll have to use nvm.
Install nvm
Install node version 14.17.3
Create .nvmrc folder at root level of the project you're working on
Run nvm use
Run npm install to install your project dependencies
And that's it... you can use any Node version on your M1 or M2 Macs.
PD: I think you need to have Rosetta installed in order to install NVM on new macs. You can install it simply by running:
usr/sbin/softwareupdate –install-rosetta –agree-to-license
Hope it helps!!! 🙌🏻

Related

NPM Error: Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' })

Having an NPM error I cannot get around. Note: This project is working fine on an intel Mac but not an M2 Mac. Both NPM and Node are working with a different project. NPM Version 8.11.0 and node version 16.16.0.
This is what I get on a npm install. However trying to use npm at all within this project gives me a similar error. I've uninstalled NPM and node and reinstalled without luck.
Any ideas?
code 1
npm ERR! path /Users/andrewleonardi/Desktop/CareerTest/CareerTest/node_modules/vlc-static
npm ERR! command failed
npm ERR! command sh -c node install
npm ERR! /Users/andrewleonardi/Desktop/CareerTest/CareerTest/node_modules/which/which.js:10
npm ERR! Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' })
npm ERR! ^
npm ERR!
npm ERR! Error: not found: vlc
npm ERR! at getNotFoundError (/Users/andrewleonardi/Desktop/CareerTest/CareerTest/node_modules/which/which.js:10:17)
npm ERR! at /Users/andrewleonardi/Desktop/CareerTest/CareerTest/node_modules/which/which.js:57:18
npm ERR! at new Promise (<anonymous>)
npm ERR! at step (/Users/andrewleonardi/Desktop/CareerTest/CareerTest/node_modules/which/which.js:54:21)
npm ERR! at /Users/andrewleonardi/Desktop/CareerTest/CareerTest/node_modules/which/which.js:71:22
npm ERR! at new Promise (<anonymous>)
npm ERR! at subStep (/Users/andrewleonardi/Desktop/CareerTest/CareerTest/node_modules/which/which.js:69:33)
npm ERR! at /Users/andrewleonardi/Desktop/CareerTest/CareerTest/node_modules/which/which.js:80:22
npm ERR! at /Users/andrewleonardi/Desktop/CareerTest/CareerTest/node_modules/isexe/index.js:42:5
npm ERR! at /Users/andrewleonardi/Desktop/CareerTest/CareerTest/node_modules/isexe/mode.js:8:5 {
npm ERR! code: 'ENOENT'
npm ERR! }
This was indeed a Mac M2 issue / CPU related issue.
This post saved the day: zsh: bad CPU type in executable: node
Steps to correcting:
#1: Delete package-lock.json file
#2: softwareupdate --install-rosetta

NPM Install "Cannot Find Module ' node-darwin-arm64/package.json' on M1 Chip

I know different versions of this question have been asked, but I've yet to see a solution that doesn't involve installing with rosetta or faking the architecture with zsh. I use bash and would like to not deal with Rosetta where possible.
I'm a node newbie and am struggling to figure out what's even failing.
Node - v16.14.0
NPM - 8.3.1
Yarn - 1.22.17
I get the same errors with npm or yarn.
Any advice is appreciated. Thanks.
npm ERR! code 1
npm ERR! path /Users/joefedorowicz/Development/xwingui/react-ui/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#12.22.6.
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/joefedorowicz/.npm/_logs/2022-02-16T15_52_10_981Z-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/joefedorowicz/Development/xwingui/react-ui/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:108:19)
npm ERR! at ChildProcess.<anonymous> (/Users/joefedorowicz/Development/xwingui/react-ui/node_modules/node-bin-setup/index.js:18:27)
npm ERR! at ChildProcess.emit (node:events:520:28)
npm ERR! at maybeClose (node:internal/child_process:1092:16)
npm ERR! at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5) {
npm ERR! code: 'MODULE_NOT_FOUND',
npm ERR! requireStack: [
npm ERR! '/Users/joefedorowicz/Development/xwingui/react-ui/node_modules/node/installArchSpecificPackage.js'
npm ERR! ]
npm ERR! }
Reinstalling node with this arch flag worked for me:
$ nvm uninstall 14
$ arch -x86_64 zsh
$ nvm install 14
$ nvm alias default 14
As per this post.

Unable to install dev-dependency in node 0.10.x Error: No compatible version found:

I am trying to run an old node project with node version as "0.10.x" and npm version as "1.4.x".
I created a nodenv which has node version as 0.10.9 and npm version as 1.2.24
The project has a dev-dependency of "load-grunt-tasks": "~0.6.0".
But when I am trying npm install using npm install load-grunt-tasks#~0.6.0, I am getting the following errors:
npm ERR! Error: No compatible version found: multimatch#'^0.3.0'
npm ERR! Valid install targets:
npm ERR! ["0.1.0","0.2.0","0.3.0","1.0.0","1.0.1","2.0.0","2.1.0","3.0.0","4.0.0","5.0.0"]
npm ERR! at installTargetsError (/mnt/c/Users/harsh/OneDrive/Documents/ONITO/software-services/hcare/OphthalmoCare-development/env-0.10/lib/node_modules/npm/lib/cache.js:709:10)
npm ERR! at /mnt/c/Users/harsh/OneDrive/Documents/ONITO/software-services/hcare/OphthalmoCare-development/env-0.10/lib/node_modules/npm/lib/cache.js:631:10
npm ERR! at saved (/mnt/c/Users/harsh/OneDrive/Documents/ONITO/software-services/hcare/OphthalmoCare-development/env-0.10/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:138:7)
npm ERR! at Object.oncomplete (fs.js:107: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 Linux 4.4.0-19041-Microsoft
npm ERR! command "/mnt/c/Users/harsh/OneDrive/Documents/ONITO/software-services/hcare/OphthalmoCare-development/env-0.10/bin/node" "/mnt/c/Users/harsh/OneDrive/Documents/ONITO/software-services/hcare/OphthalmoCare-development/env-0.10/bin/npm" "install" "load-grunt-tasks#~0.6.0"
npm ERR! cwd /mnt/c/Users/harsh/OneDrive/Documents/ONITO/software-services/hcare/OphthalmoCare-development
npm ERR! node -v v0.10.9
npm ERR! npm -v 1.2.24
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /mnt/c/Users/harsh/OneDrive/Documents/ONITO/software-services/hcare/OphthalmoCare-development/npm-debug.log
npm ERR! not ok code 0
or sometimes the dependency error gets replaced with
npm ERR! Error: No compatible version found: findup-sync#'^0.1.2'
npm ERR! Valid install targets:
npm ERR! ["0.1.0","0.1.1","0.1.2","0.1.3","0.2.0","0.2.1","0.3.0","0.4.0","0.4.1","0.4.2","0.4.3","1.0.0","2.0.0","3.0.0","4.0.0"]
Version 0.6.0 of load-grunt-tasks is 7 years old, so it's recommended to upgrade it anyway.
It's interesting/strange that it thinks there is no compatible version, even though it literally gives a list of versions, including one that should be compatible. Might be a bug due to using such old NPM version like 1.2.24, as this has been reported before it seems.

Ember JS on Rasp PI

I was trying Ember JS on my RASP Pi. Unfortunately i was unable to proceed with ember installation with my npm due to below error :
npm ERR! Error: No compatible version found: broccoli-merge-trees#'^2.0.0'
npm ERR! Valid install targets:
npm ERR! ["0.1.3","0.1.4","0.2.0","0.2.1","0.2.2","0.2.3","0.2.4","1.0.0","1.1.0","1.1.1","1.1.2","1.1.3","1.1.4","1.1.5","1.2.0","1.2.1","1.2.2","1.2.3","1.2.4","2.0.0"]
npm ERR! at installTargetsError (/usr/local/lib/node_modules/npm/lib/cache.js:685:10)
npm ERR! at /usr/local/lib/node_modules/npm/lib/cache.js:607:10
npm ERR! at saved (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:138:7)
npm ERR! at Object.oncomplete (fs.js:107: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 Linux 4.9.35-v7+
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "ember-cli#2.13"
npm ERR! cwd /home/pi/Documents/myWorkspace/node-v0.10.2
npm ERR! node -v v0.10.2
npm ERR! npm -v 1.2.15
NPM version currently installed on my pi is :1.2.15
Any help is appreciated
Your version of Node looks like it is too old.
Try installing the latest version of Node by running the following commands:
wget http://node-arm.herokuapp.com/node_latest_armhf.deb
sudo dpkg -i node_latest_armhf.deb

fails installing node package using npm on debian

I have just built a server and installed NodeJS (compiled from source). I can install global packages using npm but can't install anything locally:
$ npm install restify
npm ERR! Error: Attempt to unlock restify#~2.6.2, which hasn't been locked
npm ERR! at unlock (/usr/local/lib/node_modules/npm/lib/cache.js:1304:11)
npm ERR! at cb (/usr/local/lib/node_modules/npm/lib/cache.js:646:5)
npm ERR! at /usr/local/lib/node_modules/npm/lib/cache.js:655:20
npm ERR! at /usr/local/lib/node_modules/npm/lib/cache.js:1290:7
npm ERR! at /usr/local/lib/node_modules/npm/node_modules/lockfile/lockfile.js:167:38
npm ERR! at OpenReq.Req.done (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:144:5)
npm ERR! at OpenReq.done (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:64:22)
npm ERR! at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Linux 3.5.0-23-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "restify"
npm ERR! cwd /home/likewise-open/COVENTRY/aa7401/bookshop
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/likewise-open/.../npm-debug.log
npm ERR! not ok code 0
$
I am running the current versions of node and npm:
$ node -v
v0.10.26
$ npm -v
1.4.3
$
I am having the same issues with the request package as well.
I am the owner of the folder and all the files int contains.
Does anyone know what is going on?
The issue may be the permissions on the .npm directory in the home directory. I belatedly found this post:
NPM cannot install dependencies - Attempt to unlock something which hasn't been locked
Unfortunately until I get into work tomorrow I have no way to confirm this.

Resources