Laravel-mix error in syntax when there is none

Asked

Viewed 154 times

-1

Good evening guys, I’m trying to run NPM RUN DEV and when I do he accuses a mistake that doesn’t make sense to me (despite being a total beginner in Latin).

[webpack-cli] /var/www/html/guild-cd17/webpack.mix.js:26
"scripts": {
     ^

SyntaxError: Unexpected token ':'
at new Script (vm.js:101:7)
at NativeCompileCache._moduleCompile (/var/www/html/guild-cd17/node_modules/v8-compile- 
cache/v8-compile-cache.js:240:18)
at Module._compile (/var/www/html/guild-cd17/node_modules/v8-compile-cache/v8-compile- 
cache.js:184:36)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (/var/www/html/guild-cd17/node_modules/v8-compile-cache/v8-compile- 
cache.js:159:20)
at module.exports (/var/www/html/guild-cd17/node_modules/laravel- 
mix/setup/webpack.config.js:8:5)
at /var/www/html/guild-cd17/node_modules/webpack-cli/lib/webpack-cli.js:908:43
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] development: `mix`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the [email protected] development 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!     /home/rafael/.npm/_logs/2021-01-30T22_30_18_667Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] dev: `npm run development`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the [email protected] dev 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!     /home/rafael/.npm/_logs/2021-01-30T22_30_18_732Z-debug.log

Below is my file webpack.mix.js

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

/* |-------------------------------------------------------------------------- | Mix Asset Management |-------------------------------------------------------------------------- | | Mix provides a clean, Fluent API for Defining some Webpack build Steps | for your Laravel Applications. By default, we are compiling the CSS | file for the application as well as bundling up all the JS files. | */

mix.js('resources/js/scripts.js', 'public/js')
.postCss('resources/css/styles.css', 'public/css', [
    require('postcss-import'),
    require('tailwindcss'),
    require('autoprefixer')
.setPublicPath('public')
]);

if (mix.inProduction()) {
mix.version();
};

"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",
"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"
}

I am since 13:00 trying to solve researching and turning but so far nothing. I appreciate the help.

1 answer

0

I had a similar problem (the syntax error was different but it also looked like an invalid error).

The solution for me was to update Node and npm.

To check the Node version: node -v

To check the npm version: npm -v

You did not mention which operating system you use. I will pass the instructions to Ubuntu/Linux.

To update the Node (instructions taken from https://phoenixnap.com/kb/update-node-js-version and of https://github.com/nvm-sh/nvm#Installing-and-updating):

sudo apt update
sudo apt install build-essential checkinstall libssl-dev
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
nvm install node

To update the npm:

npm update -g

In my case it was the Node that was outdated.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.