Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

pt844931's avatar

err occurs on npm install laravel 5.7

I m on an project of an old repository, i tryed to install anything composer works right now and is stable but their seems to be a problem with node modules, espically node-sass i think. I deleted the package-lock already, but if i do that it installs anything but then errors occur with npm run dev etc. so i started at the beginning. i already deinstalled node sass reinstalled it, installed only sasss nothing seems to work. i tryed to single update laravel-mix but then it crashes the whole system. My node version is v14.18.2 and npm is v8.2.0. the insatlled node-sass version is v4.9.4 in laravel mix v2.1.14. This is the whole error message i get ---

npm ERR! code 1
npm ERR! path /var/www/html/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /usr/bin/node /var/www/html/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   '/usr/bin/node',
npm ERR! gyp verb cli   '/var/www/html/node_modules/node-gyp/bin/node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (/var/www/html/node_modules/which/which.js:13:12)
npm ERR! gyp verb `which` failed     at F (/var/www/html/node_modules/which/which.js:68:19)
npm ERR! gyp verb `which` failed     at E (/var/www/html/node_modules/which/which.js:80:29)
npm ERR! gyp verb `which` failed     at /var/www/html/node_modules/which/which.js:89:16
npm ERR! gyp verb `which` failed     at /var/www/html/node_modules/isexe/index.js:42:5
npm ERR! gyp verb `which` failed     at /var/www/html/node_modules/isexe/mode.js:8:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:191:21)
npm ERR! gyp verb `which` failed  python2 Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (/var/www/html/node_modules/which/which.js:13:12)
npm ERR! gyp verb `which` failed     at F (/var/www/html/node_modules/which/which.js:68:19)
npm ERR! gyp verb `which` failed     at E (/var/www/html/node_modules/which/which.js:80:29)
npm ERR! gyp verb `which` failed     at /var/www/html/node_modules/which/which.js:89:16
npm ERR! gyp verb `which` failed     at /var/www/html/node_modules/isexe/index.js:42:5
npm ERR! gyp verb `which` failed     at /var/www/html/node_modules/isexe/mode.js:8:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:191:21) {
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python
npm ERR! gyp verb `which` failed     at getNotFoundError (/var/www/html/node_modules/which/which.js:13:12)
npm ERR! gyp verb `which` failed     at F (/var/www/html/node_modules/which/which.js:68:19)
npm ERR! gyp verb `which` failed     at E (/var/www/html/node_modules/which/which.js:80:29)
npm ERR! gyp verb `which` failed     at /var/www/html/node_modules/which/which.js:89:16
npm ERR! gyp verb `which` failed     at /var/www/html/node_modules/isexe/index.js:42:5
npm ERR! gyp verb `which` failed     at /var/www/html/node_modules/isexe/mode.js:8:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:191:21)
npm ERR! gyp verb `which` failed  python Error: not found: python
npm ERR! gyp verb `which` failed     at getNotFoundError (/var/www/html/node_modules/which/which.js:13:12)
npm ERR! gyp verb `which` failed     at F (/var/www/html/node_modules/which/which.js:68:19)
npm ERR! gyp verb `which` failed     at E (/var/www/html/node_modules/which/which.js:80:29)
npm ERR! gyp verb `which` failed     at /var/www/html/node_modules/which/which.js:89:16
npm ERR! gyp verb `which` failed     at /var/www/html/node_modules/isexe/index.js:42:5
npm ERR! gyp verb `which` failed     at /var/www/html/node_modules/isexe/mode.js:8:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:191:21) {
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
npm ERR! gyp ERR! stack     at PythonFinder.failNoPython (/var/www/html/node_modules/node-gyp/lib/configure.js:484:19)
npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (/var/www/html/node_modules/node-gyp/lib/configure.js:406:16)
npm ERR! gyp ERR! stack     at F (/var/www/html/node_modules/which/which.js:68:16)
npm ERR! gyp ERR! stack     at E (/var/www/html/node_modules/which/which.js:80:29)
npm ERR! gyp ERR! stack     at /var/www/html/node_modules/which/which.js:89:16
npm ERR! gyp ERR! stack     at /var/www/html/node_modules/isexe/index.js:42:5
npm ERR! gyp ERR! stack     at /var/www/html/node_modules/isexe/mode.js:8:5
npm ERR! gyp ERR! stack     at FSReqCallback.oncomplete (fs.js:191:21)
npm ERR! gyp ERR! System Linux 5.4.0-91-generic
npm ERR! gyp ERR! command "/usr/bin/node" "/var/www/html/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /var/www/html/node_modules/node-sass
npm ERR! gyp ERR! node -v v14.18.2
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2022-03-23T12_48_14_898Z-debug-0.log

Package.json ↓

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch": "npm run development -- --watch",
        "watch-poll": "npm run watch -- --watch-poll",
        "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
        "prod": "npm run production",
        "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
    },
    "devDependencies": {
        "bootstrap": "~4.1.3",
        "cross-env": "~5.2.0",
        "jquery": "~3.3.1",
        "laravel-mix": "~2.1.14",
        "lodash": "~4.17.11",
        "popper.js": "~1.14.4",
        "@fortawesome/fontawesome-free": "^5.4.2"
    },
    "dependencies": {
        "morris.js06": "^0.6.3",
        "raphael": "^2.2.7"
    }
}

if anybody has an idea what i can do, responses will be great!

0 likes
31 replies
cullobsidian7's avatar

Try removing node-sass from from your package.json and also rename node_modules folder then run npm install.

pt844931's avatar

@Sinnbeck Okay it seems the installation worked. But now if im parsing an command like npm run dev it throws that error

> watch
> npm run development -- --watch


> development
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch"

[webpack-cli] Error: Unknown option '--hide-modules'
[webpack-cli] Run 'webpack --help' to see available commands and options
pt844931's avatar

I changed now the Scripts in guessing that these are the problems i had these in other projects already. But now it throws command "mix" not found. do i need to do something else?

Sinnbeck's avatar

@pt844931 Can you show what you have now in package.json? The command should just be

"development": "mix",
pt844931's avatar

@Sinnbeck Scripts are like that

{
    "scripts": {
        "dev": "npm run development",
        "development": "mix",
        "watch": "mix watch",
        "watch-poll": "mix watch -- --watch-options-poll=1000",
        "hot": "mix watch --hot",
        "prod": "npm run production",
        "production": "mix --production"
    },
pt844931's avatar

And the Dependencies

    "devDependencies": {
        "@fortawesome/fontawesome-free": "^5.4.2",
        "bootstrap": "~4.1.3",
        "cross-env": "~5.2.0",
        "jquery": "~3.3.1",
        "laravel-mix": "6.*",
        "lodash": "~4.17.11",
        "popper.js": "~1.14.4",
        "resolve-url-loader": "^5.0.0",
        "sass": "^1.49.9",
        "sass-loader": "^12.6.0"
    },
Sinnbeck's avatar

@pt844931 can you try renaming your package.lock to package.lock.old and remove node_modules. Then run npm install. And now try npm run dev

pt844931's avatar

@Sinnbeck still the same error... maybe some compatibility problems with node npm versions?

pt844931's avatar

if i run the command in the terminal of my vm it get stucked then i break the command and it throws another error

ERROR in ./resources/sass/app.scss
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
ValidationError: Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.
 - options has an unknown property 'uglify'. These properties are valid:
   object { implementation?, api?, sassOptions?, additionalData?, sourceMap?, webpackImporter?, warnRuleAsWarning? }
    at validate (/var/www/html/node_modules/webpack/node_modules/schema-utils/dist/validate.js:105:11)
    at Object.getOptions (/var/www/html/node_modules/webpack/lib/NormalModule.js:585:19)
    at Object.loader (/var/www/html/node_modules/sass-loader/dist/index.js:27:24)
    at processResult (/var/www/html/node_modules/webpack/lib/NormalModule.js:758:19)
    at /var/www/html/node_modules/webpack/lib/NormalModule.js:860:5
    at /var/www/html/node_modules/loader-runner/lib/LoaderRunner.js:399:11
    at /var/www/html/node_modules/loader-runner/lib/LoaderRunner.js:251:18

1 ERROR in child compilations (Use 'stats.children: true' resp. '--stats-children' for more details)
webpack compiled with 2 errors
pt844931's avatar

@Sinnbeck I updated now node to v16.14.2 and npm to v8.5.0 but still the error which i last parsed in.

pt844931's avatar

Okay and now it crashed all again, seems that was not a good choice ^^

pt844931's avatar

@Sinnbeck Yeah a bit strange if i use it inside my phpstorm terminal it throws command 'mix' not found but in my terminal of the vm it throws -->

ERROR in ./resources/sass/app.scss
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
ValidationError: Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.
 - options has an unknown property 'uglify'. These properties are valid:
   object { implementation?, api?, sassOptions?, additionalData?, sourceMap?, webpackImporter?, warnRuleAsWarning? }
    at validate (/var/www/html/node_modules/webpack/node_modules/schema-utils/dist/validate.js:105:11)
    at Object.getOptions (/var/www/html/node_modules/webpack/lib/NormalModule.js:585:19)
    at Object.loader (/var/www/html/node_modules/sass-loader/dist/index.js:27:24)
    at processResult (/var/www/html/node_modules/webpack/lib/NormalModule.js:758:19)
    at /var/www/html/node_modules/webpack/lib/NormalModule.js:860:5
    at /var/www/html/node_modules/loader-runner/lib/LoaderRunner.js:399:11
    at /var/www/html/node_modules/loader-runner/lib/LoaderRunner.js:251:18

1 ERROR in child compilations (Use 'stats.children: true' resp. '--stats-children' for more details)
webpack compiled with 2 errors
Sinnbeck's avatar

@pt844931 Can you show your mix config file. That could the source of the problem if it uses some old syntax. I personally cleared mine, and wrote the configuration from scratch when I upgraded :)

pt844931's avatar

@Sinnbeck Okay i see that, i never really watched over the webpack.mix file :D. That Raphael package is from the core developer implemented package which now is also not loading

const mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.autoload({ 'raphael': ['Raphael'] })
    .js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css', {
        purifyCss: true,
        uglify: {
            extractComments: 'all'
        }
    });

if (mix.inProduction()) {
    mix.version();
}
Sinnbeck's avatar

@pt844931 Not sure what that is. Did you try removing it from the config file and see if it works then?

const mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix .js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css', {
        purifyCss: true,
        uglify: {
            extractComments: 'all'
        }
    });

if (mix.inProduction()) {
    mix.version();
}
pt844931's avatar

@Sinnbeck Okay so i erased all the plugin options in the sass method, also there was a problem in my scss file there was an package was outdated i commented that out and now it seems to work. at least npm run dev is working in the terminal of vm, but the commands are not working in the integrated terminal of the IDE. And the npm run watch script loads one time but does not detect an change in the scss file. And also the command is working but there are no changes in the css file.

Sinnbeck's avatar

@pt844931 Ok this is getting kinda hard to debug without the code... I would ignore your IDE for now (until you are done) and just go with the terminal if that somewhat works.. So with npm run dev it now works completely or?

pt844931's avatar

@Sinnbeck Yeah, npm run dev is working right now and i also saw that the css file is actual so it gets updates. So i can handle the Js and css over npm run dev script for now. I can maybe do an copy later of the repo and send to you then we can take a look over it again! :)

pt844931's avatar

@Sinnbeck Alright then i write later again. Right now i try to do some stuff, atleast we could make one script working :D But many thanks for the good help!!!

Sinnbeck's avatar

@pt844931 Happy to help. You should get laravel upgraded as well as that seems a bit overdue :)

pt844931's avatar

@Sinnbeck Yeah, i thought about that but the administrator of the company is afraid that the tool could be destroyed, if we do that ^^. Its pretty important that this thing is working. ^^

Sinnbeck's avatar

@pt844931 ah that sucks. But if it ain't broken.. As long as it's not accessible from the outside and it does not need any updates on the laravel part

pt844931's avatar

@Sinnbeck For me its already working good enough, just for you if you want to take a look of the code. :)

Please or to participate in this conversation.