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?
Run npm cache clean and try again
Try to update npm. I got the same error and it's worked for me.
If you are using nvm read here about updation
Related
[webpack-cli] Error: mix.react() is now a feature flag. Use mix.js(source, destination).react() instead
at React.register (F:\Server\work\reactlaravel\lrpc1\node_modules\laravel-mix\src\components\React.js:15:19)
at Object.components.<computed> [as react] (F:\Server\work\reactlaravel\lrpc1\node_modules\laravel-mix\src\components\ComponentRegistrar.js:118:53)
at Object.<anonymous> (F:\Server\work\reactlaravel\lrpc1\webpack.mix.js:14:5)
at Module._compile (F:\Server\work\reactlaravel\lrpc1\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (F:\Server\work\reactlaravel\lrpc1\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
at module.exports (F:\Server\work\reactlaravel\lrpc1\node_modules\laravel-mix\setup\webpack.config.js:3:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! # development: `mix`
npm ERR! Exit status 2
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\info\AppData\Roaming\npm-cache\_logs\2021-01-06T04_36_25_320Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! # dev: `npm run development`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the # 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! C:\Users\info\AppData\Roaming\npm-cache\_logs\2021-01-06T04_36_25_340Z-debug.log
To fix this issue you need to replace this code.
mix.react('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css');
With the following code in the webpack.mix.js file which you can find in the Laravel app root directory.
mix.js('resources/js/app.js', 'public/js')
.react()
.sass('resources/sass/app.scss', 'public/css', [
//
]);
These changes are rolled up in Laravel Mix v6. Read the following for further changes. https://github.com/JeffreyWay/laravel-mix/blob/628f6062cceb77610b1813e3179abcbd043a4642/UPGRADE.md#update-your-npm-scripts
try to change the script in package.json
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --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 --disable-host-check --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 --config=node_modules/laravel-mix/setup/webpack.config.js"
},
I found the same problem before and try this :
Delete node_modules folder and package-lock.json
reinstall package using npm install
Try run npm run dev again.
For the details see https://github.com/laravel-mix/laravel-mix/issues/2774.
Had the same problem, just removed node_modules and installed it again successfully:
rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install
npm run dev
source: https://github.com/JeffreyWay/laravel-mix/issues/1072
try to run
npm install
then run
npm install && npm run dev
it help me to solved this problem, btw im using laravel 8
I am trying to do a fresh install of Laravel 8 with Livewire basic authentication. Basic Laravel installs fine but when installing Jetstream and running "npm install && npm run dev", I get the error.
I found this link where it indicates that there is a problem with laravel mix:
https://laravel-mix.com/docs/5.0/installation
where says:
You won't find a webpack.config.js file in your project root. By default, Laravel defers to the config file from this repo. However, should you need to configure it, you may copy the file to your project root, and then update your package.json NPM scripts accordingly: cp node_modules/laravel-mix/setup/webpack.config.js ./.
but I don't understand exactly what I have to do.
update your package.json with what ??
Copy the webpack.config.js file to the project's root folder, rerun npm install and npm run dev and the problem persists.
The server is Centos7. I will appreciate help with the problem as I am absolutely stuck with this issue.
I'm about to go to Taylor's house to ask for an explanation! Thanks!
cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js
/home/myproyect/public_html/proyect/proyectlar/node_modules/cross-env/src/index.js:23
)
^
SyntaxError: Unexpected token )
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/myproyect/public_html/proyect/proyectlar/node_modules/cross-env/src/bin/cross-env.js:3:18)
npm ERR! Linux 3.10.0-1160.6.1.el7.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "development"
npm ERR! node v6.17.1
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! # development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # development script 'cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/myproyect/public_html/proyect/proyectlar/npm-debug.log
npm ERR! Linux 3.10.0-1160.6.1.el7.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "dev"
npm ERR! node v6.17.1
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! # dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # dev script 'npm run development'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run development
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/myproyect/public_html/proyect/proyectlar/npm-debug.log
Update you npm and nodejs.
I had the same problem, and after update them, it works.
npm - 6.14.8
node - 14.15.1
I randomly started getting this error message when I try to run npm run watch. I don't know what I did that would cause it to have an error since I never touched any of the files related to laravel-mix.
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch"
module.js:549
throw err;
^
Error: Cannot find module './Assert'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/node_modules/laravel-mix/src/Api.js:1:76)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
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 "--watch"`
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.
Tried running npm update and npm install to get the latest files but it didn't help.
I even tried manually adding the Assert.js file, but I kept getting new errors with each one that I fixed. There must be a better solution.
I deleted laravel-mix from node_modules and ran npm install again and it changed my error to:
Error: Cannot find module './transform'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/node_modules/ajv-keywords/keywords/index.js:18:14)
Ended up getting npm run watch to work by deleting the node_modules directory and running npm install to get all files fresh. Not sure why I had to delete the node_modules folder to get the fresh files, but at least its working.
I am working on a laravel project and trying to add some less stylesheets.
However, when I change the webpack.min.js from this:
let 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/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css');
to:
let 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/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css');
mix.less('resources/assets/less/main.less', 'public/css');
My npm stops working. When I try to execute npm run dev after these changes I get the following errors:
> # dev /Applications/MAMP/htdocs/***.dev
> npm run development
> # development /Applications/MAMP/htdocs/***.dev
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
Additional dependencies must be installed. This will only take a moment.
/bin/sh: yarn: command not found
child_process.js:515
throw err;
^
Error: Command failed: yarn add less-loader less --save
/bin/sh: yarn: command not found
at checkExecSyncError (child_process.js:472:13)
at execSync (child_process.js:512:13)
at installDependencies (/Applications/MAMP/htdocs/***.dev/node_modules/laravel-mix/src/Verify.js:127:5)
at Function.dependency (/Applications/MAMP/htdocs/***.dev/node_modules/laravel-mix/src/Verify.js:103:13)
at Api.less (/Applications/MAMP/htdocs/***.dev/node_modules/laravel-mix/src/Api.js:113:16)
at Object.<anonymous> (/Applications/MAMP/htdocs/***.dev/webpack.mix.js:16:5)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
npm ERR! Darwin 16.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "development"
npm ERR! node v6.11.2
npm ERR! npm v3.10.10
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 '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! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! 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! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Applications/MAMP/htdocs/***.dev/npm-debug.log
npm ERR! Darwin 16.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
npm ERR! node v6.11.2
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! # dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # dev script 'npm run development'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run development
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Applications/MAMP/htdocs/***.dev/npm-debug.log
I don't know what the problem is and already tried reïnstalling npm and laravel mix. Also cleared npm cache..
Try running the following:
npm install -g yarn
Then try again
I am trying to run following command: npm run dev. However, it is giving an error as
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
module.js:471
throw err;
^
Error: Cannot find module 'lodash._baseclone'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/var/www/html/korsall-clean/node_modules/node-
notifier/node_modules/lodash.clonedeep/index.js:9:17)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
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! /home/ubuntu/.npm/_logs/2017-06-07T10_34_11_411Z-
debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # 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/ubuntu/.npm/_logs/2017-06-07T10_34_11_426Z-
debug.log
I have removed node_modules folder and re-installed it, but still it is giving same error.
Please guide me wher
There is a very similar error that I found in this thread: https://github.com/meteor/meteor/issues/7221#issuecomment-226595754
There is a comment there that says the problem is related to the windows max path limitation of 260 characters. I tend to believe this is correct since I know I don't have the problem on my device that has the long paths enabled in windows - https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation
I'm getting the crash on my build server which is running another version of windows.
Try this npm i --save lodash._baseclone