Building node errors on npm install

Issue #16821 duplicate
Jirka Doubek
created an issue

When running on node alpine images, we are getting following error:

sh: can't create builderror.log: Permission denied
> node-sass@4.9.2 install /opt/atlassian/pipelines/agent/build/node_modules/node-sass
> node scripts/install.js
Unable to save binary /opt/atlassian/pipelines/agent/build/node_modules/node-sass/vendor/linux_musl-x64-57 : { Error: EACCES: permission denied, mkdir '/opt/atlassian/pipelines/agent/build/node_modules/node-sass/vendor'

Adding a temp hack of unset NPM_CONFIG_USER solves the problem, but this shouldnt be done like that.

Comments (6)

  1. Máté Hajzso

    Hi, we are having the exact same issue. Weird thing is, we didn't change anything that could cause this, and if I try to Re-run a 2 day old commit (that was successful) it is still successful. However, if I revert or hard reset to that commit, and try to run it again, we get this error. All of our nodeJS builds are affected.

    + npm install
    npm WARN notice [SECURITY] mime has the following vulnerability: 1 moderate. Go here for more details: https://nodesecurity.io/advisories?search=mime&version=1.3.6 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
    npm WARN notice [SECURITY] hoek has the following vulnerability: 1 moderate. Go here for more details: https://nodesecurity.io/advisories?search=hoek&version=2.16.3 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
    
    > node-sass@4.9.2 install /opt/atlassian/pipelines/agent/build/node_modules/node-sass
    > node scripts/install.js
    
    Unable to save binary /opt/atlassian/pipelines/agent/build/node_modules/node-sass/vendor/linux_musl-x64-59 : { Error: EACCES: permission denied, mkdir '/opt/atlassian/pipelines/agent/build/node_modules/node-sass/vendor'
        at Object.fs.mkdirSync (fs.js:909:18)
        at sync (/opt/atlassian/pipelines/agent/build/node_modules/mkdirp/index.js:71:13)
        at Function.sync (/opt/atlassian/pipelines/agent/build/node_modules/mkdirp/index.js:77:24)
        at checkAndDownloadBinary (/opt/atlassian/pipelines/agent/build/node_modules/node-sass/scripts/install.js:114:11)
        at Object.<anonymous> (/opt/atlassian/pipelines/agent/build/node_modules/node-sass/scripts/install.js:157:1)
        at Module._compile (module.js:649:30)
        at Object.Module._extensions..js (module.js:660:10)
        at Module.load (module.js:561:32)
        at tryModuleLoad (module.js:501:12)
        at Function.Module._load (module.js:493:3)
      errno: -13,
      code: 'EACCES',
      syscall: 'mkdir',
      path: '/opt/atlassian/pipelines/agent/build/node_modules/node-sass/vendor' }
    
    > uglifyjs-webpack-plugin@0.4.6 postinstall /opt/atlassian/pipelines/agent/build/node_modules/webpack/node_modules/uglifyjs-webpack-plugin
    > node lib/post_install.js
    
    
    > node-sass@4.9.2 postinstall /opt/atlassian/pipelines/agent/build/node_modules/node-sass
    > node scripts/build.js
    
    Building: /usr/local/bin/node /opt/atlassian/pipelines/agent/build/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
    gyp info it worked if it ends with ok
    gyp verb cli [ '/usr/local/bin/node',
    gyp verb cli   '/opt/atlassian/pipelines/agent/build/node_modules/node-gyp/bin/node-gyp.js',
    gyp verb cli   'rebuild',
    gyp verb cli   '--verbose',
    gyp verb cli   '--libsass_ext=',
    gyp verb cli   '--libsass_cflags=',
    gyp verb cli   '--libsass_ldflags=',
    gyp verb cli   '--libsass_library=' ]
    gyp info using node-gyp@3.7.0
    gyp info using node@9.10.1 | linux | x64
    gyp verb command rebuild []
    gyp verb command clean []
    gyp verb clean removing "build" directory
    gyp verb command configure []
    gyp verb check python checking for Python executable "python2" in the PATH
    gyp verb `which` failed Error: not found: python2
    gyp verb `which` failed     at getNotFoundError (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:13:12)
    gyp verb `which` failed     at F (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:68:19)
    gyp verb `which` failed     at E (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:80:29)
    gyp verb `which` failed     at /opt/atlassian/pipelines/agent/build/node_modules/which/which.js:89:16
    gyp verb `which` failed     at /opt/atlassian/pipelines/agent/build/node_modules/isexe/index.js:42:5
    gyp verb `which` failed     at /opt/atlassian/pipelines/agent/build/node_modules/isexe/mode.js:8:5
    gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:170:21)
    gyp verb `which` failed  python2 { Error: not found: python2
    gyp verb `which` failed     at getNotFoundError (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:13:12)
    gyp verb `which` failed     at F (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:68:19)
    gyp verb `which` failed     at E (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:80:29)
    gyp verb `which` failed     at /opt/atlassian/pipelines/agent/build/node_modules/which/which.js:89:16
    gyp verb `which` failed     at /opt/atlassian/pipelines/agent/build/node_modules/isexe/index.js:42:5
    gyp verb `which` failed     at /opt/atlassian/pipelines/agent/build/node_modules/isexe/mode.js:8:5
    gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:170:21)
    gyp verb `which` failed   stack: 'Error: not found: python2\n    at getNotFoundError (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:13:12)\n    at F (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:68:19)\n    at E (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:80:29)\n    at /opt/atlassian/pipelines/agent/build/node_modules/which/which.js:89:16\n    at /opt/atlassian/pipelines/agent/build/node_modules/isexe/index.js:42:5\n    at /opt/atlassian/pipelines/agent/build/node_modules/isexe/mode.js:8:5\n    at FSReqWrap.oncomplete (fs.js:170:21)',
    gyp verb `which` failed   code: 'ENOENT' }
    gyp verb check python checking for Python executable "python" in the PATH
    gyp verb `which` failed Error: not found: python
    gyp verb `which` failed     at getNotFoundError (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:13:12)
    gyp verb `which` failed     at F (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:68:19)
    gyp verb `which` failed     at E (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:80:29)
    gyp verb `which` failed     at /opt/atlassian/pipelines/agent/build/node_modules/which/which.js:89:16
    gyp verb `which` failed     at /opt/atlassian/pipelines/agent/build/node_modules/isexe/index.js:42:5
    gyp verb `which` failed     at /opt/atlassian/pipelines/agent/build/node_modules/isexe/mode.js:8:5
    gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:170:21)
    gyp verb `which` failed  python { Error: not found: python
    gyp verb `which` failed     at getNotFoundError (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:13:12)
    gyp verb `which` failed     at F (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:68:19)
    gyp verb `which` failed     at E (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:80:29)
    gyp verb `which` failed     at /opt/atlassian/pipelines/agent/build/node_modules/which/which.js:89:16
    gyp verb `which` failed     at /opt/atlassian/pipelines/agent/build/node_modules/isexe/index.js:42:5
    gyp verb `which` failed     at /opt/atlassian/pipelines/agent/build/node_modules/isexe/mode.js:8:5
    gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:170:21)
    gyp verb `which` failed   stack: 'Error: not found: python\n    at getNotFoundError (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:13:12)\n    at F (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:68:19)\n    at E (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:80:29)\n    at /opt/atlassian/pipelines/agent/build/node_modules/which/which.js:89:16\n    at /opt/atlassian/pipelines/agent/build/node_modules/isexe/index.js:42:5\n    at /opt/atlassian/pipelines/agent/build/node_modules/isexe/mode.js:8:5\n    at FSReqWrap.oncomplete (fs.js:170:21)',
    gyp verb `which` failed   code: 'ENOENT' }
    gyp ERR! configure error 
    gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
    gyp ERR! stack     at PythonFinder.failNoPython (/opt/atlassian/pipelines/agent/build/node_modules/node-gyp/lib/configure.js:492:19)
    gyp ERR! stack     at PythonFinder.<anonymous> (/opt/atlassian/pipelines/agent/build/node_modules/node-gyp/lib/configure.js:406:16)
    gyp ERR! stack     at F (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:68:16)
    gyp ERR! stack     at E (/opt/atlassian/pipelines/agent/build/node_modules/which/which.js:80:29)
    gyp ERR! stack     at /opt/atlassian/pipelines/agent/build/node_modules/which/which.js:89:16
    gyp ERR! stack     at /opt/atlassian/pipelines/agent/build/node_modules/isexe/index.js:42:5
    gyp ERR! stack     at /opt/atlassian/pipelines/agent/build/node_modules/isexe/mode.js:8:5
    gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:170:21)
    gyp ERR! System Linux 4.14.48-coreos-r2
    gyp ERR! command "/usr/local/bin/node" "/opt/atlassian/pipelines/agent/build/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
    gyp ERR! cwd /opt/atlassian/pipelines/agent/build/node_modules/node-sass
    gyp ERR! node -v v9.10.1
    gyp ERR! node-gyp -v v3.7.0
    gyp ERR! not ok 
    Build failed with error code: 1
    npm WARN The package postcss-syntax is included as both a dev and production dependency.
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
    
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! node-sass@4.9.2 postinstall: `node scripts/build.js`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the node-sass@4.9.2 postinstall script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /root/.npm/_logs/2018-08-01T11_04_44_745Z-debug.log
    Skipping cache upload for failed step
    Searching for test report files in directories named [test-results, failsafe-reports, test-reports, surefire-reports] down to a depth of 4
    Finished scanning for test reports. Found 0 test report files.
    Merged test suites, total number tests is 0, with 0 failures and 0 errors.
    
  2. Log in to comment