0

I am working on a Laravel project. I have installed the Laravel project from scratch. My laptop's OS is Windows 10. I have installed the npm install. Then I run "npm run dev". Then I got the following error.

> @ development C:\Users\Acer\Desktop\LaravelProjects\PatheinDirectory
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

C:\Users\Acer\Desktop\LaravelProjects\PatheinDirectory\node_modules\cross-env\src\index.js:87
  const envVars = {...process.env}
                   ^^^

SyntaxError: Unexpected token ...
    at createScript (vm.js:74:10)
    at Object.runInThisContext (vm.js:116:10)
    at Module._compile (module.js:533:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\Acer\Desktop\LaravelProjects\PatheinDirectory\node_modules\cross-env\src\bin\cross-env.js:3:18)
npm ERR! code ELIFECYCLE
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ 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!     C:\Users\Acer\AppData\Roaming\npm-cache\_logs\2020-08-16T14_19_31_375Z-debug.log

I tried deleting the node_modules folder and then tried running the npm run dev again. It did not work.

I also tried running the following command after deleting the node_modules folder too.

npm install --global cross-env

It did not work either. How can I fix it?

Wai Yan Hein
  • 13,651
  • 35
  • 180
  • 372

2 Answers2

0

Run npm cache clean and try again

Sobir
  • 167
  • 2
  • 7
0

Try to update npm. I got the same error and it's worked for me.

If you are using nvm read here about updation