A few days ago, the company released the latest M1 macbookPro, I was very happy to start work, but when USING NPM or YARN to install dependencies, there was an error, instant crash, Internet for a while, finally fixed, now record. Hope to help some small partners….
Error message: 😭
Divided into the following steps
Checking the Node Version
First check whether your Node version is the same as the Node-sass version used in the project.
If you are interested in stackOverflow, check it out
Use NVM to manage nodeJS versions
It is recommended to use NVM to manage your Node versions if versions are inconsistent
M1 CHIP NVM Installation Guide
- If you have Homebrew installed, you can use the name below to install it
brew install nvm
Copy the code
- If you don’t have Homebrew, install it as follows
The curl - o - https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bashCopy the code
Note: I have not used this method, I do not know whether there is a problem
- After the installation is complete, you need to configure environment variables. Bash users need to configure variables in ~/.bash_profile, and ZSH users need to configure configuration files in ~/.zshrc
# NVM configuration export NVM_DIR = "/ opt/homebrew/Cellar/NVM / 0.38.0" # here for your NVM installation directory [-s "$NVM_DIR/NVM. Sh"] &&. "$NVM_DIR/nvm.sh" [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"Copy the code
Then restart the terminal
- Then use NVM to install the node corresponding to your Version of Node-sass
Note ⚠️ : Earlier versions of Node do not support the M1 chip and may cause installation failures, so it is important to open your terminal using Rosetta
Go to the Terminal App in the application, right-click Show Introduction, and select Rosetta to open
Then use the following command to install
nvm i v14
Copy the code
The installation is complete (see NVM usage for details)
Install dependencies
With all of the above done, node_sass can be installed
Rm -rf node_modules # Delete yarn/ NPM install --target_arch=x64 # and install x64 dependencies. If you failed to install x64 dependencies directly, add thisCopy the code
Welcome correction ✌️