简体   繁体   中英

yarn install symfony/webpack-encore

I want to use Webpack Encore in a Symfony 4 project and, when I follow installation guide of Yarn https://yarnpkg.com/lang/en/docs/install/ , I get this error message :

# 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".

What I did

I used this Docker image : 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

After that, when I use yarn install I get the error message.

My Webpack Encore version :

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

yarn install try to get @symfony/webpack-encore@0.17.1. How to modify that?

Log

# 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

Thank you.

If I use yarn install --ignore-engines , it's working...

# 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:

EDIT : Ok, the problem comes from the NodeJS version in Debian. You need to install a version> 6 in this way:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM