Eloïse's avatar

Laravel mix npm run dev on linux produce SyntaxError: missing ) after argument list

I can't use npm run dev|prod|watch on my staging linux server. It produces this :

 npm run production

glob error [Error: EACCES: permission denied, scandir '/root/.npm/_logs'] {
  errno: -13,
  code: 'EACCES',
  syscall: 'scandir',
  path: '/root/.npm/_logs'
}

> production
> mix --production

/var/www/html/preprodCerf2021/node_modules/laravel-mix/bin/cli.js:2
basedir=$(dirname "$(echo "LARACASTS_SNIPPET_PLACEHOLDER" | sed -e 's,\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1031:15)
    at Module._compile (node:internal/modules/cjs/loader:1065:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
    at node:internal/main/run_main_module:17:47

nodeJs is up to date v 16.8.0 and npm v 7.21.0 my the compilation works perfectly on my windows dev machine.

0 likes
14 replies
Sinnbeck's avatar

Can you try running npm rebuild and then try again?

Sinnbeck's avatar

@Eloïse Can you try adding mix.setPublicPath('.') to the webpack.mix.js file and see if that helps?

Sinnbeck's avatar

@Eloïse Can you perhaps check if you are running an old version of laravel mix? Try installing the newest version (6.x)

Sinnbeck's avatar

@Eloïse There does LARACASTS_SNIPPET_PLACEHOLDER come from? Your own code/config?

I cannot find it anywhere in the source code.

Or try showing your production script in package.json

Sinnbeck's avatar

Perhaps just simply try npx mix --production

Eloïse's avatar

@Sinnbeck Here is my package.json :

{
    "private": true,
    "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": {
        "@tailwindcss/postcss7-compat": "^2.0.2",
        "autoprefixer": "^9.8.6",
        "axios": "^0.21",
        "laravel-mix": "^6.0.6",
        "laravel-mix-purgecss": "^6.0.0",
        "lodash": "^4.17.21",
        "postcss": "^8.1.14",
        "tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.0.2"
    },
    "dependencies": {
        "alpinejs": "^2.8.0",
        "fsevents": "^2.3.2"
    }
}
Sinnbeck's avatar

@Eloïse Any chance that laracasts has changed your error code ? Can you check the error again and see if it is actually the same?

Sinnbeck's avatar

Last idea

rm node_modules -rf && npm install
1 like
Eloïse's avatar

@Sinnbeck YESS it works, sometime npm is very mysterious ! Thank you so much for your help ! 😘

Sinnbeck's avatar

@Eloïse Great to hear. Please mark a best answer to close the issue :)

Please or to participate in this conversation.