BUG record | Error reported after running command yarn: Error: Cannot find module 'D:\nodejs\node_global\node_modules\yarn\bin\yarn.js'

1. BUG description

After using the yarn command to create a new vue+Vite project, an error occurred when entering the yarn command to run.
Insert image description here

2. Cause analysis

D:\nodejs\node_global\node_modulesThe npm folder is missing in the folder prompted by Error

3. Solution

1. Move npm files

Find the downloaded node.jsfolder, enter node_modulesthe folder, copy npmthe folder and paste it to the path D:\nodejs\node_global\node_moduleswhere the error was reported just now
Insert image description here
Insert image description here

2. Install vue.js with npm

npm install vue -g

3. Install vue-router with npm

npm install vue-router -g

4. Install vue scaffolding with npm

npm install vue-cli -g

5. Install yarn with npm

npm install -g yarn

6. Run yarn command

Insert image description here

4. Command summary (just copy and paste)

npm install vue -g
npm install vue-router -g
npm install vue-cli -g
npm install -g yarn
yarn

Guess you like

Origin blog.csdn.net/Alita233_/article/details/134444229