Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

command not found after installing npm package #572

Closed
4 of 7 tasks
robots4life opened this issue Apr 29, 2019 · 5 comments · Fixed by #582
Closed
4 of 7 tasks

command not found after installing npm package #572

robots4life opened this issue Apr 29, 2019 · 5 comments · Fixed by #582
Assignees

Comments

@robots4life
Copy link

ISSUE TYPE

  • Bug Report

Checklist

OS / ENVIRONMENT

  1. Host operating system and version:
    Distributor ID: Ubuntu
    Description: Ubuntu 18.04.2 LTS
    Release: 18.04
    Codename: bionic

  2. (Windows) Native Docker or Docker Toolbox: -

  3. Docker version: Docker version 18.09.5, build e8ff056

  4. Docker Compose version: docker-compose version 1.23.2, build 1110ad01

  5. (Linux) Is SELinux enabled?: -

  6. What git commit hash are you on?: -

SUMMARY

Entering PHP container with ./shell.sh.
Installing npm packages does not seem to work

STEPS TO REPRODUCE

Run npm install -g npm-check-updates
Run ncu -v
command not found
https://www.npmjs.com/package/npm-check-updates

Run npm install -g npm-check
Run npm-check
command not found
https://github.com/dylang/npm-check

Run npm install node-sass
Run node-sass -v
command not found
https://www.npmjs.com/package/node-sass

EXPECTED BEHAVIOUR

See the version number of the installed npm package.
The package can be installed globally or locally.

ACTUAL BEHAVIOUR

command not found is returned

OTHER INFORMATION

Start command

$ docker-compose up...

File and user permissions (Linux & MacOS)

$ id uid=1000, gid=1000, docker=999
$ ls -la
root
$ ls -la data/www
root

Hi Cytopia,
new to Devilbox and really happy with it!!
Thank you for your continuous and incredible work on it!

Regarding the issue.
When I enter the PHP container of a LAMP stack selected through the .env file I can install npm packages but cannot seem to then run them from the command line. Node and npm are installed and working in the PHP container.

I have also seen this issue #122 and did run ./update-docker.sh and waited for all images to download the latest version.

I also exited, stopped and removed all containers before starting them again.
The strange things is, node-sass for example does work within a grunt task just fine, however when I try to do a conversion on the command line it tells me command not found. So I can use the package but not from the command line inside the PHP container?

module.exports = function(grunt) {

  const sass = require('node-sass')
  require('load-grunt-tasks')(grunt)

  grunt.initConfig({
    sass: {
      options: {
        implementation: sass,
        sourceMap: false
      },
      dist: {
        files: {
          'style.css': 'style.scss'
        }
      }
    }
  })

  grunt.registerTask('default', ['sass'])
}

For the other 2 packages I am not sure what is going on. I cannot use them at all rom the command line. It always tells me command not found. If would be great if these could work so I can update the packages via an updated package.json file.

I have also tried to install the packages as root as show here https://devilbox.readthedocs.io/en/latest/getting-started/enter-the-php-container.html but the result is the same. The packages are somehow not recognized on the command line.

So, thank you for any help, hope I gave you all the info you need in the report.

env.txt

@robots4life
Copy link
Author

As for finding the node-sass version in the container, this helped.

node -e "console.log(require('node-sass').info)"

Also got node-sass to work fine in the container, in addition use grunt-crontib-watch to watch for changes and faced the

Error: ENOSPC: System limit for number of file watchers reached

error, however I was able to fix that with

cat /proc/sys/fs/inotify/max_user_watches

and then

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

being outside the container.

As for npm-check-updates I have not gotten any further. No matter how I install it, with sudo, as root, it cannot find the ncu or ncu -v command.

@cytopia
Copy link
Owner

cytopia commented May 4, 2019

@robots4life

Run npm install -g npm-check-updates
Run ncu -v
command not found

The PHP-FPM container uses nvm to manage different nodejs versions. Try nvm current and nvm ls and choose a desired version prior installing.

Once you're done choosing a version all npm install commands will add the corresponding packages into: /opt/nvm/versions/node/<NPM-VERSION>/bin

They are available, but not in the path of the current shell. I am myself are also not too familiar with npm/nvm and I don't know how to automatically populate the path of them. All existing packages (which come by default) have been symlinked from: /opt/nvm/versions/node/<NPM-VERSION>/bin to /usr/local/bin/

TL;DR

Your packages are here: /opt/nvm/versions/node/v12.0.0/bin/

@cytopia cytopia self-assigned this May 18, 2019
@cytopia cytopia added documentation and removed bug labels May 18, 2019
@robots4life
Copy link
Author

Thank you for your reply.

Tried the direct folder location you mentioned, see the global installed packages there, still when issuing the command it just cannot find the package. Going to keep trying.

Perhaps I manage somehow and if I do I will report back. Would be super sweet to be able to just npm install inside the container and project folder and have everything sorted and ready to go.

@cytopia cytopia mentioned this issue May 21, 2019
@cytopia
Copy link
Owner

cytopia commented May 21, 2019

@robots4life I've added npm binaries location to bash $PATH and they will be available directly after install. PR is here: #582

@fkaminski
Copy link

Normally you can use the bin executables either by calling them in an npm script or by using node's npx command on cli:
https://blog.npmjs.org/post/162869356040/introducing-npx-an-npm-package-runner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants