docker-magento icon indicating copy to clipboard operation
docker-magento copied to clipboard

"node" and "npm": executable file not found in $PATH

Open ignaciomella opened this issue 4 years ago • 18 comments

Description I need to use npm and nodejs, but it seems that they are not installed.

Steps To Reproduce

  1. New fresh installation through automated one-liner
  2. exectute bin/npm --version and bin/node --version

Expected Result No erros.

Error: Executable file not found in $PATH

ignaciomella avatar Apr 25 '22 00:04 ignaciomella

I just came here to report the same thing. The latest image doesn't have node and npm in the PATH. The previous version works though - markoshust/magento-php:7.4-fpm-13

TerrorSquad avatar Apr 25 '22 15:04 TerrorSquad

I ran into this as well. Ended up having to bash into the container and use this link to install node/npm using method #2. Then, you'll need to update the cli commands on your local to run the command as npx instead of npm.

joshuabromero avatar Apr 25 '22 16:04 joshuabromero

obviously the new 'streamlined' php images don't have node support at all - I do not know if this is on purpose or by accident

dirkreitz avatar Apr 26 '22 06:04 dirkreitz

As I build my own php images, I still install node with the following lines:

RUN apt-get install -y gnupg
&& curl -sL https://deb.nodesource.com/setup_current.x | bash -
&& apt-get install -y nodejs
&& mkdir /var/www/.config /var/www/.npm
&& chown app:app /var/www/.config /var/www/.npm
&& npm install -g grunt-cli

Mark had the same setup, but was using an outdated version of node

dirkreitz avatar Apr 26 '22 07:04 dirkreitz

The thing is... there is no reference to this strimlined image being not compatible with the custom CLI Commands.

If so, it would be nice to reference this lack of support somewhere in the README.md

ignaciomella avatar Apr 26 '22 14:04 ignaciomella

First of all, thank you to mark and commu for this great work.

I am also stuck with this same problem. I don't want to override the image to stay up to date.

Before the problem is fixed, are there any old versions compatible with grunt? Ex: markoshust/magento-php:7.4-fpm-{version}

Or create a "bin/setup-grunt" script. Would you have an idea ? When I ran the first command. I had an error : bin/cli apt install nodejs npm

E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

Thanks for all,

malou72 avatar Apr 26 '22 15:04 malou72

I would like to give Mark a chance to answer, why he dismissed the installation of node. As far as I know, php:7.4-fpm-13 should work ...

dirkreitz avatar Apr 26 '22 16:04 dirkreitz

I confirmed that npm and node does not available on the latest Automated Setup which has markoshust/magento-php:8.1-fpm-0

TuVanDev avatar May 02 '22 14:05 TuVanDev

After installing the node and npm by myself as @dirkreitz suggested, I had a problem with the source maps of the css files. For some reason it wasnt showing on the chrome .

I solve it by implementing this suggesion https://github.com/magento/magento2/issues/20952#issuecomment-501650316

x3: {
        area: 'frontend',
        name: 'Grudado/x3',
        locale: 'pt_BR',
        options: {
            sourceMap: true,
            strictImports: false,
            sourceMapRootpath: '/',
            dumpLineNumbers: false, // use 'comments' instead false to output line comments for source
            ieCompat: false
        },
        files: [
            'css/styles-m',
            'css/styles-l',
            'css/email',
            'css/email-inline'
        ],
        dsl: 'less'
    },

and less.js

var lessOptions = {
    options: {
        sourceMap: true,
        strictImports: false,
        sourceMapRootpath: '/',
        sourceMapFileInline: 'true',
        dumpLineNumbers: false, // use 'comments' instead false to output line comments for source
        ieCompat: false
    },
    setup: {
        files: {
            '<%= path.css.setup %>/setup.css': '<%= path.less.setup %>/_setup.less'
        }
    },
    updater: {
        files: {
            '<%= path.css.updater %>/updater.css': '<%= path.less.setup %>/_setup.less'
        }
    },
    documentation: {
        files: {
            '<%= path.doc %>/docs.css': '<%= path.doc %>/source/docs.less'
        }
    }
};

vy-shmal avatar May 04 '22 15:05 vy-shmal

Sorry for the delay in my response of this issue, just got over a big course creation bender.

I forgot to note the removal of node & npm in the latest images. If you absolutely need these, I'd recommend reverting back to the previous Docker images for the time being.

I'd like to move node/npm to their own containers. I wasn't sure if the code is dependent upon the PHP images or not, but there should be a way to make the binaries accessible within their own containers. This would provide the ability to update node/npm sources without affecting the PHP image.

I'll try to take a look at this soon, but if anyone wants to take a stab at this, let me know!

markshust avatar May 06 '22 18:05 markshust

Or create a "bin/setup-grunt" script. Would you have an idea ? When I ran the first command. I had an error : bin/cli apt install nodejs npm

E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

Thanks for all,

bin/root apt update
bin/root apt install nodejs npm
cd src
cp Gruntfile.js.sample Gruntfile.js
cp grunt-config.json.sample grunt-config.json
cp package.json.sample package.json
cd ..
bin/root npm install -g grunt-cli
bin/npm install
bin/npm update

artmouse avatar May 11 '22 12:05 artmouse

Thanks @artmouse for your reply !

I choosed to downgrade markoshust/magento-php:7.4-fpm-13 and It works.

malou72 avatar May 12 '22 13:05 malou72

use bin/rootnotty bin/rootnotty apt install nodejs npm standalone container

drtrem86 avatar May 15 '22 10:05 drtrem86

I use markoshust/magento-php:8.1-fpm-develop node --version v14.19.1 npm --version 6.14.16

thinkfix avatar May 16 '22 07:05 thinkfix

I was planning on putting npm & node in their own container, but it seems there is a lot of dependencies such as cache-clean not working unless node is installed. I'll be adding them back into this main image momentarily and will rebuild these images 👍 Really sorry if this has inconvenienced anyone, but will get these packages added very soon.

markshust avatar May 25 '22 19:05 markshust

I did forget there is an open PR which could potentially add this as a separate container instead https://github.com/markshust/docker-magento/pull/699/files .... looking at this before rebuilding images.

markshust avatar May 25 '22 20:05 markshust

Rebuilding PHP images/tags https://github.com/markshust/docker-magento/actions/runs/2387076836

markshust avatar May 25 '22 20:05 markshust

Released in 43.0.0

markshust avatar May 26 '22 15:05 markshust