How to fix "Cannot find module 'node-darwin-arm64/package.json"

krishna121996

krishnaprasad

Posted on June 11, 2023

How to fix "Cannot find module 'node-darwin-arm64/package.json"

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'


Enter fullscreen mode Exit fullscreen mode

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,

Image description

Now check the arch flag in the terminal using command arch in terminal. By default it will be arm64.

Image description

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 


Enter fullscreen mode Exit fullscreen mode

Image description

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



Enter fullscreen mode Exit fullscreen mode

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...

💖 💪 🙅 🚩
krishna121996
krishnaprasad

Posted on June 11, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related