I'm having problems installing node-sass on my server.
root@west:/usr/lib/node_modules# npm install -g node-sass npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.) npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142 /usr/bin/node-sass -> /usr/lib/node_modules/node-sass/bin/node-sass > [email protected] install /usr/lib/node_modules/node-sass > node scripts/install.js Unable to save binary /usr/lib/node_modules/node-sass/vendor/linux-x64-79 : Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/node-sass/vendor' at Object.mkdirSync (fs.js:887:3) at sync (/usr/lib/node_modules/node-sass/node_modules/mkdirp/index.js:72:13) at Function.sync (/usr/lib/node_modules/node-sass/node_modules/mkdirp/index.js:78:24) at checkAndDownloadBinary (/usr/lib/node_modules/node-sass/scripts/install.js:114:11) at Object.<anonymous> (/usr/lib/node_modules/node-sass/scripts/install.js:157:1) at Module._compile (internal/modules/cjs/loader.js:1147:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10) at Module.load (internal/modules/cjs/loader.js:996:32) at Function.Module._load (internal/modules/cjs/loader.js:896:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) { errno: -13, syscall: 'mkdir', code: 'EACCES', path: '/usr/lib/node_modules/node-sass/vendor' } > [email protected] postinstall /usr/lib/node_modules/node-sass > node scripts/build.js Building: /usr/bin/node /usr/lib/node_modules/node-sass/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 [ gyp verb cli '/usr/bin/node', gyp verb cli '/usr/lib/node_modules/node-sass/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 verb cli ] gyp info using [email protected] gyp info using [email protected] | 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` succeeded python2 /usr/bin/python2 gyp verb check python version `/usr/bin/python2 -c "import sys; print "2.7.17 gyp verb check python version .%s.%s" % sys.version_info[:3];"` returned: %j gyp verb get node dir no --target version specified, falling back to host node version: 13.11.0 gyp verb command install [ '13.11.0' ] gyp verb install input version string "13.11.0" gyp verb install installing version: 13.11.0 gyp verb install --ensure was passed, so won't reinstall if already installed gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/13.11.0" gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/node-sass/.node-gyp" gyp verb tmpdir == cwd automatically will remove dev files after to save disk space gyp verb command install [ '--node_gyp_internal_noretry', '13.11.0' ] gyp verb install input version string "13.11.0" gyp verb install installing version: 13.11.0 gyp verb install --ensure was passed, so won't reinstall if already installed gyp verb install version not already installed, continuing with install 13.11.0 gyp verb ensuring nodedir is created /usr/lib/node_modules/node-sass/.node-gyp/13.11.0 gyp WARN install got an error, rolling back install gyp verb command remove [ '13.11.0' ] gyp verb remove using node-gyp dir: /usr/lib/node_modules/node-sass/.node-gyp gyp verb remove removing target version: 13.11.0 gyp verb remove removing development files for version: 13.11.0 gyp WARN install got an error, rolling back install gyp verb command remove [ '13.11.0' ] gyp verb remove using node-gyp dir: /usr/lib/node_modules/node-sass/.node-gyp gyp verb remove removing target version: 13.11.0 gyp verb remove removing development files for version: 13.11.0 gyp ERR! configure error gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/node-sass/.node-gyp' gyp ERR! System Linux 4.15.0-88-generic gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/node-sass/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" gyp ERR! cwd /usr/lib/node_modules/node-sass gyp ERR! node -v v13.11.0 gyp ERR! node-gyp -v v3.8.0 gyp ERR! not ok Build failed with error code: 1 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] postinstall: `node scripts/build.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] 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/2020-03-26T08_39_09_785Z-debug.log The issue seems to be around permissions:
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/node-sass/.node-gyp'
Yet it seems ok here:
root@west:/usr/lib/node_modules# ls -lh total 8.0K drwxr-xr-x 6 root root 4.0K Mar 25 20:18 @babel drwxr-xr-x 9 root root 4.0K Mar 25 20:17 npm Am I missing something?
UPDATE: I've even tried using NVM to configure the node version:
curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh -o install_nvm.sh bash install_nvm.sh source ~/.profile nvm install 12.16.1 nvm use 12.16.1 But I still get errors:
sudo npm install -g node-sass npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.) npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142 /root/.npm-global/bin/node-sass -> /root/.npm-global/lib/node_modules/node-sass/bin/node-sass > [email protected] install /root/.npm-global/lib/node_modules/node-sass > node scripts/install.js internal/modules/cjs/loader.js:979 throw err; ^ Error: Cannot find module '/root/.npm-global/lib/node_modules/node-sass/scripts/install.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:976:15) at Function.Module._load (internal/modules/cjs/loader.js:859:27) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47 { code: 'MODULE_NOT_FOUND', requireStack: [] } npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] install: `node scripts/install.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] install 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/2020-03-26T10_10_11_044Z-debug.log UPDATE 2:
So I have managed to install it with:
sudo npm install --save-dev --unsafe-perm node-sass npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.) npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142 > [email protected] install /root/node_modules/node-sass > node scripts/install.js Cached binary found at /root/.npm/node-sass/4.13.1/linux-x64-79_binding.node > [email protected] postinstall /root/node_modules/node-sass > node scripts/build.js Binary found at /root/node_modules/node-sass/vendor/linux-x64-79/binding.node Testing binary Binary is fine npm WARN saveError ENOENT: no such file or directory, open '/root/package.json' npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN enoent ENOENT: no such file or directory, open '/root/package.json' npm WARN root No description npm WARN root No repository field. npm WARN root No README data npm WARN root No license field. + [email protected] added 172 packages from 137 contributors and audited 528 packages in 7.275s 3 packages are looking for funding run `npm fund` for details found 0 vulnerabilities However, how do I now access it? I've tried:
sass --help node-sass --help Neither seem to work. "whereis" comes back with:
whereis node-sass node-sass: /usr/bin/node-sass