纱线安装symfony / webpack-encore

时间:2018-03-05 16:18:01

标签: symfony yarnpkg symfony4 webpack-encore

我想在Symfony 4项目中使用Webpack Encore,当我按照Yarn https://yarnpkg.com/lang/en/docs/install/的安装指南时,我收到以下错误消息:

# yarn install
yarn install v1.5.1
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
error @symfony/webpack-encore@0.17.1: The engine "node" is incompatible with this module.
Expected version ">=6.0.0". error An unexpected error occurred: "Found incompatible module".
info If you think this is a bug, please open a bug report with the information provided
in "/var/www/html/jobeet/yarn-error.log".

我做了什么

我使用了这个Docker镜像:php:7.2-fpm

apt-get install apt-transport-https \
                gnupg -y --no-install-recommends

echo "alias nodejs=node" >> ~/.bashrc && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && \
apt-get install yarn -y && \
apt-get clean && \
yarn config set proxy http://user:password@proxy:port && \
yarn config set https-proxy http://user:password@proxy:port

之后,当我使用yarn install时,我收到错误消息。

我的Webpack Encore版本:

# composer show | grep encore
symfony/webpack-encore-pack         v1.0.2             A pack for Symfony...

yarn install尝试获取@ symfony / webpack-encore @ 0.17.1。如何修改?

日志

# cat /var/www/html/jobeet/yarn-error.log

Arguments: 
  /usr/bin/nodejs /usr/share/yarn/bin/yarn.js install

PATH: 
  /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Yarn version: 
  1.5.1

Node version: 
  4.8.2

Platform: 
  linux x64

npm manifest: 
  {
      "devDependencies": {
          "@symfony/webpack-encore": "^0.17.0"
      },
      "license": "UNLICENSED",
      "private": true,
      "scripts": {
          "dev-server": "encore dev-server",
          "dev": "encore dev",
          "watch": "encore dev --watch",
          "build": "encore production"
      }
  }

yarn manifest: 
  No manifest

Lockfile: 
  No lockfile

Trace: 
  Error: Found incompatible module
      at MessageError.Error (native)
      at new MessageError (/usr/share/yarn/lib/cli.js:186:110)
      at checkOne (/usr/share/yarn/lib/cli.js:62444:11)
      at Object.check (/usr/share/yarn/lib/cli.js:62463:5)
      at /usr/share/yarn/lib/cli.js:22803:73
      at next (native)
      at step (/usr/share/yarn/lib/cli.js:98:30)
      at /usr/share/yarn/lib/cli.js:109:13
      at run (/usr/share/yarn/lib/cli.js:100334:22)
      at /usr/share/yarn/lib/cli.js:100347:28

谢谢。

1 个答案:

答案 0 :(得分:2)

如果我使用yarn install --ignore-engines,它正在运作......

# yarn install --ignore-engines
yarn install v1.5.1
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.1.3: The platform "linux" is incompatible with this module.
info "fsevents@1.1.3" is an optional dependency and failed compatibility check.
Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...




error An unexpected error occurred: "/var/www/html/jobeet/node_modules/uglifyjs-webpack-plugin: Command failed.
Exit code: 127
Command: sh
Arguments: -c node lib/post_install.js
Directory: /var/www/html/jobeet/node_modules/uglifyjs-webpack-plugin
Output:

编辑: 好吧,问题来自Debian中的NodeJS版本。 您需要安装版本> 6这样:

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions