Ich bin neu im Webpack und werde versuchen, reactJS zu lernen, aber ich finde es schwierig einzurichten. Ich habe keine Erfahrung in der Arbeit mit Webpack.Probleme beim Einrichten von reactjs, babel mit webpack
Hier ist was ich getan habe.
ich installieren Abhängigkeiten, die
istbabel-loader babel-core babel-preset-es2015 babel-preset-react webpack react react-dom
Nachdem alle Abhängigkeiten zu installieren. Ich bearbeite die package.json
Hier ist mein package.json
{
"name": "reactjs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"react": "^15.3.2",
"react-dom": "^15.3.2"
},
"devDependencies": {
"babel-cli": "^6.18.0",
"babel-core": "^6.18.2",
"babel-loader": "^6.2.7",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"webpack": "^1.13.3"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"babel": "babel", // I put babel and webpack
"webpack": "webpack"
},
"author": "",
"license": "ISC"
}
webpack.config.js
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: './js/app.js',
output: {
path: __dirname,
filename: './js/app-dist.js'
},
watch: true,
module: {
loaders: [
{
test: /.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react']
}
}
]
}
}
Hier ist der Fehler ausgelöst.
npm ERR! Windows_NT 6.1.7600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "webpack"
npm ERR! node v6.7.0
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! [email protected] webpack: `webpack`
npm ERR! Exit status 3221225501
npm ERR!
npm ERR! Failed at the [email protected] webpack script 'webpack'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the reactjs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs reactjs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls reactjs
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! E:\reactjs\npm-debug.log
Das Skript kompiliert, aber es gibt immer einen Fehler.
Jede Hilfe wäre willkommen. Salamat (Danke)
Wenn Sie beginnen, können Sie auf einem vorhandenen Projekt basieren. Wie: https://github.com/gaearon/react-hot-boilerplate es hat ein Webpack reagiert, auch dieses ist gut https://github.com/facebookincubator/create-react-app. Sie können daran experimentieren. – Hosar
@Hosar Ich habe es versucht, aber es hat denselben Fehler. Woher kommt es, von Knoten oder Betriebssystem? –
Es ist kein Problem mit dem Betriebssystem. Ich benutze es selbst auf Windows. Sie sollten einfach versuchen, eine andere Version des Knotens zu verwenden und zu überprüfen, ob sie für Sie funktioniert. –