Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`npm install` results in `cb() never called!` when running in Docker

I have a project with rather small package.json file:

{
    "name": "chilldev-web",
    "version": "2.1.0-SNAPSHOT",
    "description": "Client-side build tool for a project.",
    "license": "UNLICENSED",
    "private": true,
    "dependencies": {
        "internal-edge-render": "file:/root/.m2/repository/pl/chilldev/internal/internal-edge-render/0.1.2/internal-edge-render-0.1.2.tar.gz",
        "react": "16.6.1",
        "react-dom": "16.6.1",
        "react-helmet": "5.2.0",
        "director": "1.2.8"
    },
    "devDependencies": {
        "typescript": "2.9.2",
        "browserify": "16.2.3",
        "gulp": "3.9.1",
        "tslint": "5.11.0",
        "tslint-react": "3.6.0",
        "cssnano": "4.1.7",
        "autoprefixer": "9.3.1",
        "envify": "4.1.0",
        "uglifyify": "5.0.1",
        "sassdoc": "2.5.1",
        "typedoc": "0.13.0",
        "gulp-typedoc": "2.2.0",
        "gulp-postcss": "8.0.0",
        "gulp-tslint": "8.1.3",
        "gulp-jscpd": "0.0.8",
        "gulp-sass": "4.0.2",
        "gulp-typescript": "4.0.2",
        "gulp-install": "1.1.0",
        "gulp-zip": "4.2.0",
        "gulp-concat": "2.6.1",
        "gulp-header": "2.0.5",
        "gulp-uglify": "3.0.1",
        "vinyl-source-buffer": "1.1.1",
        "@types/whatwg-streams": "0.0.7",
        "@types/google.analytics": "0.0.39",
        "@types/react": "16.4.18",
        "@types/react-dom": "16.0.9",
        "@types/react-helmet": "5.0.7",
        "@types/headroom": "0.7.31",
        "@types/aws-lambda": "8.10.15",
        "bourbon": "5.1.0",
        "susy": "3.0.5"
    }
}

When using local installation of Node/NPM it works fine (Node v11.0.0, NPM v6.4.1) to perform a fresh installation (rm -rf node_modules && npm install).

But when running a Dockerized task (which affects eg. CI pipeline) I got a cb() never called! error:

root@4b8396e40e22:/usr/src/app# npm install --loglevel=verbose                                                                                                                                                                                                                 
npm info it worked if it ends with ok                                                                                                                                                                                                                                          
npm verb cli [ '/usr/local/bin/node',                                                                                                                                                                                                                                          
npm verb cli   '/usr/local/bin/npm',                                                                                                                                                                                                                                           
npm verb cli   'install',                                                                                                                                                                                                                                                      
npm verb cli   '--loglevel=verbose' ]                                                                                                                                                                                                                                          
npm info using [email protected]                                                                                                                                                                                                                                                       
npm info using [email protected]                                                                                                                                                                                                                                                    
npm verb npm-session c4ce6e4ee1ed4de0                                                                                                                                                                                                                                          
npm info lifecycle [email protected]~preinstall: [email protected]
npm timing stage:loadCurrentTree Completed in 14ms                                                                                                                                                                                                                             
npm timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms                                                                                                                                                                                                               
npm timing stage:loadIdealTree:loadShrinkwrap Completed in 899ms
npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 1603ms
npm timing stage:loadIdealTree Completed in 3006ms
npm timing stage:generateActionsToTake Completed in 390ms
npm verb correctMkdir /root/.npm/_locks correctMkdir not in flight; initializing
npm verb lock using /root/.npm/_locks/staging-af89dff005e44f9e.lock for /usr/src/app/node_modules/.staging
npm timing audit compress Completed in 108ms
npm info audit Submitting payload of 62503bytes
npm timing audit submit Completed in 1539ms
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/audits/quick 1539ms
npm timing audit body Completed in 1ms
npm timing action:extract Completed in 6742ms
npm timing action:finalize Completed in 940ms
npm timing npm Completed in 14338ms
npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm ERR!     <https://npm.community>

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-11-07T19_09_16_380Z-debug.log

Just running the task again makes it successfull:

root@4b8396e40e22:/usr/src/app# npm install --loglevel=verbose
npm info it worked if it ends with ok
npm verb cli [ '/usr/local/bin/node',
npm verb cli   '/usr/local/bin/npm',
npm verb cli   'install',
npm verb cli   '--loglevel=verbose' ]
npm info using [email protected]
npm info using [email protected]
npm verb npm-session efbf901b4a03cead
npm info lifecycle [email protected]~preinstall: [email protected]
npm timing stage:loadCurrentTree Completed in 2177ms
npm timing stage:loadIdealTree:cloneCurrentTree Completed in 21ms
npm timing stage:loadIdealTree:loadShrinkwrap Completed in 1153ms
npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 1463ms
npm timing stage:loadIdealTree Completed in 3225ms
npm timing stage:generateActionsToTake Completed in 103ms
npm verb correctMkdir /root/.npm/_locks correctMkdir not in flight; initializing
npm verb lock using /root/.npm/_locks/staging-af89dff005e44f9e.lock for /usr/src/app/node_modules/.staging
npm verb unlock done using /root/.npm/_locks/staging-af89dff005e44f9e.lock for /usr/src/app/node_modules/.staging
npm timing stage:executeActions Completed in 16ms
npm timing stage:rollbackFailedOptional Completed in 0ms
npm info linkStuff [email protected]
npm info lifecycle [email protected]~install: [email protected]
npm info lifecycle [email protected]~postinstall: [email protected]
npm timing audit compress Completed in 25ms
npm info audit Submitting payload of 62503bytes
npm info lifecycle [email protected]~prepublish: [email protected]
npm info lifecycle [email protected]~prepare: [email protected]
npm timing stage:runTopLevelLifecycles Completed in 6162ms
npm verb saving []
npm verb shrinkwrap skipping write for package.json because there were no changes.
npm info lifecycle undefined~preshrinkwrap: undefined
npm info lifecycle undefined~shrinkwrap: undefined
npm verb shrinkwrap skipping write for package-lock.json because there were no changes.
npm info lifecycle undefined~postshrinkwrap: undefined
npm timing audit submit Completed in 2165ms
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/audits/quick 2019ms
npm timing audit body Completed in 3ms
audited 4746 packages in 8.13s
found 6 vulnerabilities (2 low, 4 high)
run `npm audit fix` to fix them, or `npm audit` for details
npm verb exit [ 0, true ]
npm timing npm Completed in 8439ms
npm info ok 

The commands above are executed in Docker image node:11.0.0. But the same result comes when I try to install Node in different images (eg. if I use maven:3.5.2-jdk-8 to run Maven project with bound npm install).

-edit-

One more detail - to fix issue with file ownership after Docker execution, I use bindfs:

DIR=`mktemp -d`
sudo bindfs --create-for-user=`id -nu` --create-for-group=`id -ng` $PWD $DIR
docker run --rm -it -v $DIR:/usr/src/app -w /usr/src/app node:11.0.0 npm install

When I run the Docker with just -v $PWD:/usr/src/app instead of temporary mount point it all works fine!

like image 852
Rafał Wrzeszcz Avatar asked Nov 08 '18 01:11

Rafał Wrzeszcz


1 Answers

You have a local dependency that you are trying to install.

"internal-edge-render": "file:/root/.m2/repository/pl/chilldev/internal/internal-edge-render/0.1.2/internal-edge-render-0.1.2.tar.gz"

Docker is unaware of it's path. Either install the dependency from npm or mount the directory into docker. Assuming the latter is no option...

Unfortunately the logs don't really help in that case.

like image 137
Eydrian Avatar answered Oct 16 '22 20:10

Eydrian