Answer the question
In order to leave comments, you need to log in
Why doesn't webpack see packages from devDependencies?
Previously, I always installed packages in the general config, now I decided to throw them in devDependencies, but it started to give an error:
My package.json:
{
"name": "aviasales_test",
"version": "1.0.0",
"main": "index.js",
"author": "Nikita Shchypylov <[email protected]>",
"license": "MIT",
"dependencies": {
"webpack": "^4.1.1",
"webpack-cli": "^2.0.11",
"webpack-dashboard": "^1.1.1"
},
"scripts": {
"build": "webpack"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"html-loader": "^0.5.5",
"html-webpack-plugin": "^3.0.6",
"react": "^16.2.0",
"react-dom": "^16.2.0"
}
}
const path = require("path");
const HtmlWebPackPlugin = require("html-webpack-plugin");
module.exports = {
entry: ["./src/index.js"],
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].js"
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: ["env"]
}
}
},
{
test: /\.html$/,
use: [
{
loader: "html-loader"
}
]
}
]
},
plugins: [
new HtmlWebPackPlugin({
template: "./public/index.html",
filename: "./index.html"
})
]
};
Answer the question
In order to leave comments, you need to log in
probably there were some errors when installing babel. try reinstalling all the packages, run npm cache clean
the working config, tried the configuration at home - it all worked
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question