vue-cli-service:运行 npm run serve 时权限被拒绝
Posted
技术标签:
【中文标题】vue-cli-service:运行 npm run serve 时权限被拒绝【英文标题】:vue-cli-service: Permission denied while running npm run serve 【发布时间】:2020-10-08 17:52:23 【问题描述】:我正在尝试运行简单的vue
项目。但是,不知何故,我无法在我的 openSUSE TW (20200615) 系统上运行它。我正在使用 NVM 进行节点安装。以下是我的环境
nvm --version # 0.35.3
node --version # v14.4.0
npm --version # 6.14.5
vue --version # @vue/cli 4.4.4
我正在学习典型的 hello world 教程
vue create hello-world
cd hello-world
npm run serve
我收到以下错误
> hello-world@0.1.0 serve /path/to/hello-world
> vue-cli-service serve
sh: /path/to/hello-world/node_modules/.bin/vue-cli-service: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! hello-world@0.1.0 serve: `vue-cli-service serve`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the hello-world@0.1.0 serve script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/user/.npm/_logs/2020-06-18T15_03_14_259Z-debug.log
我已经尝试了很多方法,例如删除 node_modules
并再次安装,如建议的 here 和 here。尝试按照建议here 使用root 帐户。我什至尝试全局安装node
并执行此操作,但仍然出现同样的错误。我试图将所有 node_module 文件的权限更改为 777 并运行。自过去 2 小时以来尝试了所有这些之后,我仍然遇到同样的错误。谁能告诉我这是怎么回事?
如果有人想要的话,这里是日志文件 (2020-06-18T15_03_14_259Z-debug.log)。
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/home/user/.nvm/versions/node/v14.4.0/bin/node',
1 verbose cli '/home/user/.nvm/versions/node/v14.4.0/bin/npm',
1 verbose cli 'run',
1 verbose cli 'serve'
1 verbose cli ]
2 info using npm@6.14.5
3 info using node@v14.4.0
4 verbose run-script [ 'preserve', 'serve', 'postserve' ]
5 info lifecycle hello-world@0.1.0~preserve: hello-world@0.1.0
6 info lifecycle hello-world@0.1.0~serve: hello-world@0.1.0
7 verbose lifecycle hello-world@0.1.0~serve: unsafe-perm in lifecycle true
8 verbose lifecycle hello-world@0.1.0~serve: PATH: /home/user/.nvm/versions/node/v14.4.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/path/to/hello-world/node_modules/.bin:/home/user/.nvm/versions/node/v14.4.0/bin:/home/user/android/Sdk/platform-tools:/var/lib/snapd/snap/bin:/usr/bin:/home/user/.pyenv/bin:/home/user/bin:/usr/local/bin:/home/user/bin:/usr/local/bin:/usr/bin:/bin:/snap/bin
9 verbose lifecycle hello-world@0.1.0~serve: CWD: /path/to/hello-world
10 silly lifecycle hello-world@0.1.0~serve: Args: [ '-c', 'vue-cli-service serve' ]
11 silly lifecycle hello-world@0.1.0~serve: Returned: code: 126 signal: null
12 info lifecycle hello-world@0.1.0~serve: Failed to exec serve script
13 verbose stack Error: hello-world@0.1.0 serve: `vue-cli-service serve`
13 verbose stack Exit status 126
13 verbose stack at EventEmitter.<anonymous> (/home/user/.nvm/versions/node/v14.4.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:315:20)
13 verbose stack at ChildProcess.<anonymous> (/home/user/.nvm/versions/node/v14.4.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:315:20)
13 verbose stack at maybeClose (internal/child_process.js:1051:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid hello-world@0.1.0
15 verbose cwd /path/to/hello-world
16 verbose Linux 5.7.1-1-default
17 verbose argv "/home/user/.nvm/versions/node/v14.4.0/bin/node" "/home/user/.nvm/versions/node/v14.4.0/bin/npm" "run" "serve"
18 verbose node v14.4.0
19 verbose npm v6.14.5
20 error code ELIFECYCLE
21 error errno 126
22 error hello-world@0.1.0 serve: `vue-cli-service serve`
22 error Exit status 126
23 error Failed at the hello-world@0.1.0 serve script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 126, true ]
【问题讨论】:
openSUSE 你启用了 SELinux 吗? @squareborg 不,它默认有apparmor
。
sh: /path/to/hello-world/node_modules/.bin/vue-cli-service: Permission denied
您是否更改了 /path/to 以便在此处粘贴,或者这真的是输出的内容?
@squareborg,已更改。原来的不一样。它是安装在 Windows 分区上的路径。类似 /mnt/windows/MyFolder
unix.stackexchange.com/questions/161999/…
【参考方案1】:
以下事情对我有用
chmod -R a+x node_modules
【讨论】:
以上是关于vue-cli-service:运行 npm run serve 时权限被拒绝的主要内容,如果未能解决你的问题,请参考以下文章
npm run serve 给出错误 sh: vue-cli-service: command not found in Vue Cli app
运行 vue-cli-service serve 时来自 Node.js 的高 CPU 使用率
npm run server 抛出错误 sh: 1: vue-cli-service: not found
Vue - 由于 webpack 版本(vue-cli-service、laravel-mix、webpack)导致 npm run serve 命令崩溃