you can find the built js file in the corresponding package directory under node_modules, and then copy it to the public directory to use. You can also go to the package's official website or git to download the built package.
this is related to the problem of laravel-mix introducing the front-end file after compilation
1. You can see mix.js ('resources/js/app.js',' public/js') in the webpack.mix.js file under the laravel project directory, which means that mix compiles: resources/js/app.js. Generate the app.js file
2 under public/js, so if you want to introduce the package installed by npm, you have to introduce it in resources/js/app.js:
window._ = require ('wangEditor'); / / globally introduce
or var wangEditor = require ('wangEditor')
conlog.log (wangEditor); / / check whether it has been successfully introduced in the console
ps:
require () will go to node_modules/ to find the wangEditor package, then find the path pointed to by the value of the main parameter in wangEditor/package.json, and load the file.
this is the correct way to introduce the npm installation package
3, to introduce the mix compiled file public/js/app.js:
< script src= "{asset ('js/app.js')}}" defer > < / script >
4 in the index.blade.php template, and to enable real-time compilation:
npm run watch
after compilation is completed, you can see
on the browser console.