These issues were commonly occurring in M1 chip users. This can be noticed after taking the clone of the project and while doing npm install.
Cannot find module 'node-darwin-arm64/package.json'
This is due to an architecture mismatch happening while installing dependencies in the system. Darwin is one of the main dependencies which will create the node folder, which is key for other dependencies to install.
To resolve the issue, install NVM (Node Version Manager) to continue installing the Node dependencies with the arch flag.
Please nvm installation guide for easy implementation.
Run nvm ls command to verify the dependencies installed properly. And it looks as below,
Now check the arch flag in the terminal using command arch in terminal. By default it will be arm64.
For M1 user, npm needs to install with i386 arch flags to avoid the darwin dependency issue error. Do uninstall the existing node version using the below command.
nvm uninstall 14.21.3 //uninstall the respective node versions
To install the node with arch flag, enter the below command to execute
arch -x86_64 zsh
Now the arch reference is pointed to i386, and make sure not to kill the terminal because this flag will remain until we terminate the terminal. To install Node with NVM, use the following command.
nvm install 14.21.3
nvm alias default 14.21.3
After all these executions, try running npm install, and now you could see in the terminal that the darwin dependency is created successfully.
Thanks for Reading, Do comment if any queries.
Happy Coding...
Top comments (3)
I was using Biome with a pnpm project. The fix was a force install
and all dependencies were reinstalled
Thank you :)
I am getting following error after executing the steps.
when i tried yarn install
I am getting following error
zsh: segmentation fault yarn install