Skip to content

Commit 61a5855

Browse files
authored
docs: add a troubleshooting page for common issues (#3479)
1 parent 0003b5d commit 61a5855

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

docs/.vuepress/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ module.exports = {
103103
'/guide/webpack',
104104
'/guide/mode-and-env',
105105
'/guide/build-targets',
106-
'/guide/deployment'
106+
'/guide/deployment',
107+
'/guide/troubleshooting'
107108
]
108109
}
109110
],

docs/guide/troubleshooting.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Troubleshooting
2+
3+
## Running installation with `sudo` or as `root`
4+
5+
If you install `@vue/cli-service` as `root` user or with `sudo`, there might be issues when running package `postinstall` scripts.
6+
7+
This is a security feature of npm. You should always avoid running npm with root privileges because install scripts can be unintentionally malicious.
8+
9+
If you must however, you can workaround this error by setting the `--unsafe-perm` flag of npm. This can be done by prefixing the command with an environment variable, i.e.
10+
11+
```bash
12+
npm_config_unsafe_perm=true vue create my-project
13+
```
14+
15+
## Symbolic Links in `node_modules`
16+
17+
If there're dependencies installed by `npm link` or `yarn link`, ESLint (and sometimes Babel as well) may not work properly for those symlinked dependencies. It is because [webpack resolves symlinks to their real locations by default](https://webpack.js.org/configuration/resolve/#resolvesymlinks), thus breaks ESLint / Babel config lookup.
18+
19+
A workaround for this issue is to manually disable symlinks resolution in webpack:
20+
21+
```js
22+
// vue.config.js
23+
module.exports = {
24+
chainWebpack: (config) => {
25+
config.resolve.symlinks(false)
26+
}
27+
}
28+
```
29+
30+
::: warning
31+
Disabling `resovle.symlinks` may break hot module reloading if your dependencies are installed by third-party npm clients that utilized symbolic links, such as`cnpm` or `pnpm`.

0 commit comments

Comments
 (0)