J'ai créé une application dans react-redux. Après cela, j'ai installé babel et webpack en utilisant le lien ci-dessous.
Voici mon fichier webpack.config.js:
> my-app@0.1.0 start /var/www/html/SFL
> webpack-dev-server â mode development â open â hot
â ï½¢wdsï½£: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.entry should be one of these:
function | object { <key>: non-empty string | [non-empty string] } | non-empty string | [non-empty string]
-> The entry point(s) of the compilation.
Details:
* configuration.entry should be an instance of function
-> A Function returning an entry object, an entry string, an entry array or a promise to these things.
* configuration.entry['main'] should be a string.
-> The string is resolved to a module which is loaded upon startup.
* configuration.entry['main'] should not contain the item 'â' twice.
* configuration.entry should be a string.
-> An entry point without name. The string is resolved to a module which is loaded upon startup.
* configuration.entry should be an array:
[non-empty string]
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app@0.1.0 start: `webpack-dev-server â mode development â open â hot`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
J'obtiens une erreur ci-dessous lorsque j'exécute le "npm start"
const path = require('path');
const HWP = require('html-webpack-plugin');
module.exports = {
entry: path.join(__dirname, '/src/index.js'),
output: {
filename: 'build.js',
//path: path.join(__dirname, '/dist')},
path: path.resolve(__dirname, 'build'),
},
module:{
rules:[{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
}]
},
plugins:[
new HWP(
{template: path.join(__dirname,'/src/index.html')}
)
]
}
J'essaye de résoudre l'erreur ci-dessus. Existe-t-il un autre moyen de résoudre cette erreur?
4 Réponses :
Essayez ceci: supprimez vos node_modules && votre package-lock.json
et exécutez à nouveau npm i.
dites-moi si cela fonctionne.
S'il existe un autre moyen ou une autre documentation pour ajouter webpack et babel dans l'application react-redux existante, je peux annuler mes modifications et essayer avec de nouvelles.
Essayez de changer votre entrée en ceci (extrait de create-react-app):
entry: [ require.resolve('webpack-dev-server/client') + '?/', require.resolve('webpack/hot/dev-server'), path.join(__dirname, '/src/index.js') ]
S'il existe un autre moyen ou une autre documentation pour ajouter webpack et babel dans l'application react-redux existante, je peux annuler mes modifications et essayer avec de nouvelles.
La structure de votre dossier doit ressembler à ceci
âââ webpack.config.js âââ src â âââ index.js
Oui .. La structure est la même. S'il existe un autre moyen ou une autre documentation pour ajouter webpack et babel dans l'application react-redux existante, je peux annuler mes modifications et essayer avec de nouvelles
avez-vous essayé de cloner ce dépôt dans votre local pour voir qu'il fonctionne réellement ou non github.com/SiddharthaChowdhury/bp-common/tree/master/app-rea ct
essayez ceci.
annuler vos modifications et exécuter npm run eject
cela activera Webpack dans votre projet
Pouvez-vous partager avec nous le fichier package.json?
ok éditer la question ..