Tag Archives: rimraf

The node rimraf module recursively deletes the contents of the folder

When using the webpack build file project, a dist directory is generated every time. Sometimes, all the old files in the dist directory need to be deleted,

In addition to the RM – RF / dist / command, you can also use the rimraf / dist / command

The function of rimraf is to package the RM - RF command in the form of package to delete files and folders, regardless of whether the folder is empty or not

Local installation: NPM install rimraf — save dev

Global installation: NPM install rimraf – G

Use: rimraf & lt; path & gt; [& lt; path & gt;…]

api:rimraf(f, [opts], callback)

Vue init webpack command error Vue cli / node_ modules/_ [email protected]@rimraf/rimraf.js :313

This is a low-level error in Vue development that can be encountered but is shared here so that it can be resolved if encountered
To explain the development environment in which this problem occurs: native Mac + NVM-managed node uses Node V8.0.0 to install vue-cli globally: NPM install vue-cli-g

Error is as follows

/Users/weiyongqiang/.nvm/versions/node/v9.2.0/lib/node_modules/vue-cli/node_modules/[email protected]@rimraf/rimraf.js:313
        throw er
        ^

Error: EACCES: permission denied, unlink '/Users/weiyongqiang/.vue-templates/webpack/.gitignore'

Error analysis
This problem is actually relatively simple. The intuitive error is that an exception is thrown on line 313 of rimraf.js. Exploring the cause of this problem requires understanding the role of rimraf.js. It uses the rm -rf command of Unix for deep package deletions. RM-RF is required to operate the corresponding permissions.
Error resolution
Run the vue command with sudo

sudo vue init webpack

Although the solution to this problem is very simple but I believe that many people will encounter, the use of Windows system, of course, will not appear the problem of authority.