K
K
K. A.2018-04-12 03:58:13
Node.js
K. A., 2018-04-12 03:58:13

Why doesn't node.js see the package when building via Laravel Mix (webpack)?

I ran into a strange problem: I installed the fotorama package in my project:
npm i fotorama --save
a new package appeared in the node_modules folder. Further, because a collector is built into Laravel, and I just need to add 1 package, I decided that I would not fence gulp, etc. and use what I have.
I added a line to /resources/assets/sass/app.scss:

// Fotorama
@import '~fotorama/fotorama.css';

Next, in /resources/assets/js/ I created the fotorama.js file:
try {
    require('fotorama');
} catch (e) {}

and in the app.js file (in the same folder) I added the line: After the performed operations, I launched the assembly with the command And I get the following error:
require('./fotorama');
npm run dev
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

 95% emitting

 WARNING  Compiled with 1 warnings                                                                                                                                                    03:45:58
This dependency was not found:

* fotorama in ./resources/assets/js/fotorama.js

To install it, you can run: npm install --save fotorama
                                                     Asset     Size  Chunks                    Chunk Names
   images/vendor/fotorama/fotorama.png?e95aace1dffd7b8683b30639b59614e2  3.22 kB          [emitted]
images/vendor/fotorama/[email protected]?0f1f99b65c03fe9212ae7ab962d3b9df  7.32 kB          [emitted]
                                                             /js/app.js  1.37 MB       0  [emitted]  [big]  /js/app
                                                           /css/app.css   203 kB    0, 0  [emitted]         /js/app, /js/app

WARNING in ./resources/assets/js/fotorama.js
Module not found: Error: Can't resolve 'fotorama' in 'D:\OSPanel\domains\project.loc\resources\assets\js'
 @ ./resources/assets/js/fotorama.js 2:4-23
 @ ./resources/assets/js/app.js
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

Why is this happening? It's interesting that he saw the CSS and compiled the fotorama.css style file from the package into app.css, but he doesn't see the js file...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question