Symfony 4.1使用webpack encore运行npm/yarn时出现错误
我按照Symfony的官方文档所述步骤进行操作,成功通过composer require webpack-encore
安装后,执行npm install
,尝试执行npm run dev
时出现以下错误。当使用yarn encore dev
时也会出现相同的权限被拒绝错误。
我正在使用Debian 9。
kamii@kamii-workstation:~$ node -v
v10.9.0
kamii@kamii-workstation:~$ npm -v
6.4.1
kamii@kamii-workstation:~$ yarn -v
1.9.4
通过npm安装:
kamii@kamii-workstation:/media/disks/Development/dev_lab_gen/exim_pos$ npm run dev
> @ dev /media/disks/Development/dev_lab_gen/exim_pos
> encore dev
sh: 1: encore: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! @ dev: `encore dev`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the @ dev 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/kamii/.npm/_logs/2018-09-03T20_11_01_530Z-debug.log
通过Yarn
kamii@kamii-workstation:/media/disks/Development/dev_lab_gen/exim_pos$ yarn encore dev
yarn run v1.9.4
$ /media/disks/Development/dev_lab_gen/exim_pos/node_modules/.bin/encore dev
/bin/sh: 1: /media/disks/Development/dev_lab_gen/exim_pos/node_modules/.bin/encore: Permission denied
error Command failed with exit code 126.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
这里是NPM日志文件。
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'dev' ]
2 info using npm@6.4.1
3 info using node@v10.9.0
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle @~predev: @
6 info lifecycle @~dev: @
7 verbose lifecycle @~dev: unsafe-perm in lifecycle true
8 verbose lifecycle @~dev: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/media/disks/Development/dev_lab_gen/exim_pos/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
9 verbose lifecycle @~dev: CWD: /media/disks/Development/dev_lab_gen/exim_pos
10 silly lifecycle @~dev: Args: [ '-c', 'encore dev' ]
11 silly lifecycle @~dev: Returned: code: 126 signal: null
12 info lifecycle @~dev: Failed to exec dev script
13 verbose stack Error: @ dev: `encore dev`
13 verbose stack Exit status 126
13 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:182:13)
13 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:182:13)
13 verbose stack at maybeClose (internal/child_process.js:961:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:250:5)
14 verbose pkgid @
15 verbose cwd /media/disks/Development/dev_lab_gen/exim_pos
16 verbose Linux 4.9.0-8-amd64
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "dev"
18 verbose node v10.9.0
19 verbose npm v6.4.1
20 error code ELIFECYCLE
21 error errno 126
22 error @ dev: `encore dev`
22 error Exit status 126
23 error Failed at the @ dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 126, true ]
node ./node_modules/.bin/encore dev
运行成功了。你能解释一下为什么用 npm/yarn 不起作用吗?谢谢。 - Kamran Akram