Tuesday, February 28, 2017

Error installing SweetAlert on Laravel through npm

When I run $ npm install sweetalert --save-dev

I get

"sweetalert": "^1.1.3"

saved to my package.json

I run $ npm run dev to compile the app.js file with webpack which loads successfully

But when I try to use the module eg

<script>
  sweetAlert("Hello world!");
</script>

I get Uncaught ReferenceError: sweetAlert is not defined

I have also tried to reference the js and css files in my header with combinations of "./node_" and "../node_" and "/node_" and so on

<script src="node_modules/sweetalert/dist/sweetalert.min.js"></script>
<link rel="stylesheet" type="text/css" href="node_modules/sweetalert/dist/sweetalert.css">

What am I missing?




via Dazzle

Advertisement