npm run dev error after bootstrap installation - laravel

Following a tutorial on vue and laravel, I managed to make a start.
Everything was all right, I even implemented my first vue-component, untill I tried to install bootstrap.
Now I get the following errors after
npm run dev
Can anyone point me in the right direction to solve this?
I tried many solutions I found online, removing the node_modules folder, clean install, update, etc.
I am afraid I messed up without really knowing where to start to figure out the problem.
This is the error:
> dev
> npm run development
> # development D:\laravel\ijsbreker_memory
> mix
× Mix
Compiled with some errors in 5.26s
ERROR in ./resources/js/components/Cards.vue 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <template>
| <div>
| <h2 > Cards </h2>
webpack compiled with 1 error
npm ERR! Windows_NT 10.0.19043
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "D:\\laravel\\ijsbreker_memory\\node_modules\\npm\\bin\\npm-cli.js" "run" "development"
npm ERR! node v14.16.0
npm ERR! npm v2.15.12
npm ERR! code ELIFECYCLE
npm ERR! # development: `mix`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # development script 'mix'.
npm ERR! 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! mix
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 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! D:laravel\ijsbreker_memory\npm-debug.log
npm ERR! code 1
npm ERR! path D:\laravel\ijsbreker_memory
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c npm run development
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\xxx\AppData\Local\npm-cache\_logs\2021-08-09T15_42_13_853Z-debug.log
The commands I gave before the trouble started were from a tutorial:
=============================================================================
Step 2 : Install Laravel/UI
Laravel UI is an official library that comes with predefined UI components.
To install Laravel/UI run the command:
composer require laravel/ui
Step 3 : Install Bootstrap 5 in Laravel
In this step please follow up with me the commands on the same order and don't skip any of the commands listed bellow .
php artisan ui bootstrap
You may noticed that this command will install Bootstrap 4, the reason you have to run it is that it will set up a lot of things for you so you don't have to do it yourself compared of installing bootstrap 5 directly.
Now we will switch the Bootstrap version to Bootstrap 5 using this commands.
Note that you should run both this commands on the same order so you wont get any issues.
npm install bootstrap#next #popperjs/core --save-dev
npm install bootstrap #popperjs/core --save-dev
next, you only have to:
npm install
npm run dev
If you followed up with me you will have Bootstrap 5 installed on your Laravel project successfully. you can check wish Bootstrap version is installed on your project on package.json file.
====================================================================================
My package.json file:
{
"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": {
"#popperjs/core": "^2.9.3",
"axios": "^0.21",
"bootstrap": "^5.1.0",
"jquery": "^3.6",
"laravel-mix": "^6.0.27",
"lodash": "^4.17.19",
"popper.js": "^1.16.1",
"postcss": "^8.1.14",
"resolve-url-loader": "^3.1.2",
"sass": "^1.32.11",
"sass-loader": "^11.0.1",
"vue": "^2.6.12",
"vue-loader": "^15.9.7",
"vue-template-compiler": "^2.6.12"
},
"dependencies": {
"latest": "^0.2.0"
}
}

Which version of node.js are do you using?, probably you need upgrade your version of node, i'm using nodejs version 16.6.1 https://nodejs.org/en/download/current/ (latest).
I had before similar issues with old versions of nodejs.

Related

Vuex can not install using npm and it give an error

When I try to install Vuex using NPM commands, it gives this error.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: undefined#undefined
npm ERR! Found: vue#2.6.14
npm ERR! node_modules/vue
npm ERR! dev vue#"^2.6.12" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue#"^3.0.2" from vuex#4.0.2
npm ERR! node_modules/vuex
npm ERR! vuex#"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /home/viraj/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/viraj/.npm/_logs/2022-06-23T16_10_55_210Z-debug-0.log
I tried using npm install vuex --save and npm install vuex#next --save as well. But both of them not work for me. Why is this happen? And I will be really appreciate if anyone can give some solution for this.
Note : I'm using Vue js with my Laravel project. Here is my package.json file for further refrence.
{
"private": true,
"scripts": {
"dev": "npm run development -- --watch",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production",
"lint": "eslint resources/js"
},
"devDependencies": {
"#popperjs/core": "^2.10.2",
"axios": "^0.21.4",
"bootstrap": "^5.1.3",
"deepmerge": "^4.2.2",
"eslint": "^8.16.0",
"eslint-plugin-vue": "^9.1.0",
"laravel-mix": "^6.0.44",
"lodash": "^4.17.19",
"postcss": "^8.1.14",
"resolve-url-loader": "^3.1.2",
"sass": "^1.32.13",
"sass-loader": "^11.1.1",
"vue": "^2.6.12",
"vue-loader": "^15.9.8",
"vue-template-compiler": "^2.6.12"
},
"dependencies": {
"vue-feather-icons": "^5.1.0",
"vuetify": "^2.6.6"
}
}
You have vue2 so you need vuex3 not 4
npm install vuex#3.4.0 --save

Laravel 8 Installation - npm run dev Error

[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

How to resolve sh: react-scripts: command not found?

I used create-react-app to generate an app.
create-react-app myapp
When I run yarn start or npm start I get this error:
react-scripts start
sh: react-scripts: command not found npm ERR! file sh npm ERR! code
ELIFECYCLE npm ERR! errno ENOENT npm ERR! syscall spawn npm ERR!
myapp#0.1.0 start: react-scripts start npm ERR! spawn ENOENT npm
ERR! npm ERR! Failed at the myapp#0.1.0 start script. npm ERR! This
is probably not a problem with npm. There is likely additional logging
output above.
When I run npm ls react:
myapp#0.1.0 /Users/johnno/foosball
└── react#16.2.0
react-scripts is present.
This is my package.json:
{
"name": "myapp",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-redux": "^5.0.6",
"react-router": "^4.2.0",
"react-scripts": "1.0.17",
"redux": "^3.7.2",
"yarn": "^1.3.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
I tried the suggestions from this but to no avail. How can I fix this issue?
i solved this by deleting
node_modules
yarn.lock
manifest_lock.json
and installed packages by
npm install
or
yarn
Following steps worked for me
delete node_modules folder
delete yarn.lock if you are using yarn command or delete package-lock.json if you are using npm command
run yarn install (for yarn command) or npm install (for npm command)

Laravel npm run dev returns TypeError: chunk.sortModules is not a function

When I try to run npm run dev, I get this error. This is a fresh install, and I have it working with the same setup in another folder. I get the same error on another computer.
Versions
NPM: 5.3.0
Node: v8.4.0
test ⚑ → npm run dev master ✗ 2d
> # dev /Users/myuser/Code/testing/test
> node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
78% advanced chunk optimization/Users/myuser/Code/testing/test/node_modules/extract-text-webpack-plugin/dist/index.js:188
chunk.sortModules();
^
TypeError: chunk.sortModules is not a function
at /Users/myuser/Code/testing/test/node_modules/extract-text-webpack-plugin/dist/index.js:188:19
at /Users/myuser/Code/testing/test/node_modules/async/dist/async.js:3083:16
at eachOfArrayLike (/Users/myuser/Code/testing/test/node_modules/async/dist/async.js:1003:9)
at eachOf (/Users/myuser/Code/testing/test/node_modules/async/dist/async.js:1051:5)
at Object.eachLimit (/Users/myuser/Code/testing/test/node_modules/async/dist/async.js:3145:5)
at Compilation.<anonymous> (/Users/myuser/Code/testing/test/node_modules/extract-text-webpack-plugin/dist/index.js:184:27)
at Compilation.applyPluginsAsyncSeries (/Users/myuser/Code/testing/test/node_modules/tapable/lib/Tapable.js:206:13)
at Compilation.seal (/Users/myuser/Code/testing/test/node_modules/webpack/lib/Compilation.js:579:8)
at /Users/myuser/Code/testing/test/node_modules/webpack/lib/Compiler.js:493:16
at /Users/myuser/Code/testing/test/node_modules/tapable/lib/Tapable.js:289:11
at _addModuleChain (/Users/myuser/Code/testing/test/node_modules/webpack/lib/Compilation.js:481:11)
at processModuleDependencies.err (/Users/myuser/Code/testing/test/node_modules/webpack/lib/Compilation.js:452:13)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # dev: `node node_modules/cross-env/dist/bin/cross-env.js 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 # 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! /Users/myuser/.npm/_logs/2017-09-04T13_55_30_770Z-debug.log
the issue seems to be related to difference in packages, just today I was updating webapacker version 3 which uses webpack version 3 in rails app and I was getting this same error. The issue stoped when I updated this packages to this versions in the package.json file:
"sass-loader": "^6.0.6"
"babel-loader": "7.1.2"
"webpack": "^3.6.0"
Thanks to the suggestion of this guy: https://github.com/rails/webpacker/issues/852#issuecomment-331764386
I suggest that if you are using these packages you change to these versions to see if it works for you also.
This worked for me. When I used Yarn instead.
rm -rf node_modules
brew install yarn
yarn
yarn run dev
First, remove the webpack plugin. Then install and build yarn using the following steps:
npm install remove-webpack-plugin --save-dev
yarn install
yarn build

Heroku Build Failing Bower Error

Please Help me out I am new to everything regarding heroku and bower assume I understand very Little Here is the heroku log.
Everything with this was working until yesterday and all of a sudden minor changes won't deploy properly
bower moment#>= 2.6.0 resolved git://github.com/moment/moment.git#2.10.6
bower angular resolution Unsuitable resolution declared for angular: 1.4.4
bower ECONFLICT Unable to find suitable version for angular
npm ERR! Linux 3.13.0-57-generic
npm ERR! argv "/tmp/build_1c565364c27a4cdb7538ade6aae8f158//node-v0.12.4-linux-x64/bin/node" "/tmp/build_1c565364c27a4cdb7538ade6aae8f158/node-v0.12.4-linux-x64/bin/npm" "install"
npm ERR! node v0.12.4
npm ERR! npm v2.10.1
npm ERR! code ELIFECYCLE
npm ERR! fronted#1.0.0 postinstall: `./node_modules/bower/bin/bower install;`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fronted#1.0.0 postinstall script './node_modules/bower/bin/bower install;'.
npm ERR! This is most likely a problem with the fronted package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ./node_modules/bower/bin/bower install;
npm ERR! You can get their info via:
npm ERR! npm owner ls fronted
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
! Push rejected, failed to compile nginx-buildpack app
Here is the bower.json
{
"name": "ac",
"version": "0.0.0",
"dependencies": {
"angular": "~1.4.0",
"bootstrap": "~3.3.5",
"angular-resource": "~1.4.0",
"angular-ui-router": "~0.2.15",
"angular-bootstrap": "~0.13.0",
"spin": "~1.1.6",
"angular-spinner": "~0.6.2",
"moment-timezone": "~0.4.0",
"angular-ui-select": "~0.12.0",
"angular-sanitize": "~1.4.2",
"intl-tel-input": "~6.0.4",
"international-phone-number": "~0.0.8",
"angular-cookies": "~1.4.3",
"angular-ui-notification": "~0.0.11",
"angular-loading-bar": "~0.8.0",
"angular-sweetalert": "~1.1.0"
},
"resolutions": {
"angular": "~1.4.0"
},
"devDependencies": {
"angular-mocks": "~1.4.0"
},
"appPath": "app",
"moduleName": "frontApp",
"resolutions": {
"intl-tel-input": "~6.0.4",
"angular": "1.4.4"
}
}
I had this same issue after installing moment via bower
Adding resolutions to your bower.json seems to solve it.
Example
//dependencies
},
"resolutions": {
"angular": "1.5.0",
"moment": "2.12.0"
}

Resources