0

I use node v20.9.0, npm v10.1.0

When I running npm run watch throws the following error:

[webpack-cli] TypeError: Cannot read properties of undefined (reading 'scripts') at Object. (c:\OSPanel\domains\dispatcher\webpack.mix.js:16:4) at Module._compile (node:internal/modules/cjs/loader:1241:14) at Module._extensions..js (node:internal/modules/cjs/loader:1295:10) at Module.load (node:internal/modules/cjs/loader:1091:32) at Module._load (node:internal/modules/cjs/loader:938:12) at Module.require (node:internal/modules/cjs/loader:1115:19) at require (node:internal/modules/helpers:130:18) at module.exports (c:\OSPanel\domains\dispatcher\node_modules\laravel- mix\setup\webpack.config.js:11:5) at loadConfigByPath (c:\OSPanel\domains\dispatcher\node_modules\webpack-cli\lib\webpack-cli.js:1445:37) at async Promise.all (index 0)

My package.json

"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"
},
"devDependencies":  
    "axios": "^1.6.1",    
    "bootstrap-sass": "^3.3.7",      
    "cross-env": "^5.0.1",      
    "jquery": "^3.1.1",  
    "laravel-mix": "^6.0.49",  
    "lodash": "^4.17.4",  
    "vue": "^2.1.10",  
    "webpack": "^5.89.0",  
    "webpack-cli": "^5.1.4"  
}

My webpack.mix.js

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

mix.js('resources/assets/js/app.js', 'public/js')
    .sass('resources/assets/sass/app.scss', 'public/css').
mix.scripts([
    'public/test/jquery.easing.1.3.js',
    'public/test/retina-1.1.0.min.js',
    'public/test/jquery.cookie.js',
    'public/test/styleswitch.js',
    'public/test/jquery.smartmenus.min.js',
    'public/test/jquery.smartmenus.bootstrap.min.js',
    'public/test/owl.carousel.min.js',
    'public/test/jflickrfeed.js',
    'public/test/jquery.magnific-popup.min.js',
    'public/test/jquery.isotope.min.js',
    'public/test/swipe.js',
    'public/test/jquery.sticky.js',
    'public/test/main.js',  
],  
    'public/js/all.js').mix.scripts([
    'public/test/fileinput.min.js',
    'public/test/inputmask.js',
    'public/test/jquery.inputmask.js',
    'public/test/flash_message.js',
    'public/test/select2.min.js',
    'public/test/ru.js',
    'public/test/text_area_counter.js',
    'public/test/text_area_counter.js',
    'public/test/file_input.js',
 ], 'public/js/libs.js');

How can I fix this error?

I try reinstalling webpack-cli and clearing the npm cache (npm cache clean --force) but it did not help

8
  • Please provide the "webpack.mix.js" file content. And what is the "mix watch"? What binary is it (mix?) Commented Nov 11, 2023 at 6:25
  • @TalRofe "npm run watch" turn on watch mode and run Mix tasks . This means that after the initial build, webpack will continue to watch for changes in any of the resolved files Commented Nov 11, 2023 at 6:48
  • using ׳.sass('...').mix׳ does not seem valid. Maybe try to explain what are you trying to do? Commented Nov 11, 2023 at 7:42
  • @TalRofe I'm trying to compile JS scripts to run my project. It's legacy code so I can't explain some used solutions. While I'm running the server locally, I only see a white screen. Everything works correctly in production, but not locally Commented Nov 11, 2023 at 7:52
  • I used your same code and it alerts on an error because doing "sass(...).mix(..)" is not valid. The object return by sass(...) does not contain a method called "mix". What version is "laravel-mix" on production? Commented Nov 11, 2023 at 7:57

1 Answer 1

0

The main problem were node-sass and node-gyp. Reinstalling node-gyp and downgrading laravel-mix to v1 and node to v16.20.2 solved it

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.