Answer the question
In order to leave comments, you need to log in
Installing webpack locally?
I watch screencasts of Ilya Kantor on webpack, and for me everything was so incomprehensible at first and was difficult that I delved into the first 8 lessons all day.
Actually there are a couple of questions:
1. As I understand it, the local installation of webpack is done in the folder of the project itself and on different resources they write such a command to install it "npm install --save-dev webpack". But nothing comes out for some reason, in the console it gives errors:
npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\thehi\package.json'
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\thehi\package.
npm WARN thehi No description
npm WARN thehi No repository field.
npm WARN thehi No README data
npm WARN thehi No license field.
here, in principle, I can guess that a json config file is needed, but I'm not sure.
2. And yet it turned out to install webpack locally as in Ilya's screencast: npm i webpack. But for some reason, after installation, the node_modules folder appears in the project file, while Ilya does not have it in the screencast, but he still recues the webpack: const webpack = require('webpack');
Why is that? So everything works, but if you delete the node_modules folder, then when you restart the webpack, errors fly out. I would like to understand what is happening, maybe I'm missing something?
Answer the question
In order to leave comments, you need to log in
1. Yes, you need a package.json file, you can generate it using npm init (answering questions along the way)
2. In the second video, at the 52nd second, Ilya installs webpack "globally":
Therefore, although he does not have a node_modules folder in the project - everything works correctly.
Optional:
If you install modules locally, a node_modules folder is created where they are actually installed.
P.S. советую посмотреть его скринкаст по node.js, чтобы стало понятно, как node.js ищет пакет, в упрощенном случае: сначала локально, потом глобально (почему упрощенно? потому что, так же еще ищет сначала у вас по относительному пути с расширением .js, потом .json, потом локально тоже самое в node_modules, потом глобально... Может быть что-то еще упустил, в скринкасте по node.js это точно было)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question