gpt4 book ai didi

node.js - 尝试创建 React App 时出现 web pack 问题

转载 作者:太空宇宙 更新时间:2023-11-03 22:40:01 25 4
gpt4 key购买 nike

我正在尝试按照教程 https://www.tutorialspoint.com/reactjs/reactjs_environment_setup.htm 运行 React 应用程序,但我在运行 react 应用程序时遇到一些问题。更准确地说,请查找当我输入 npm start

时出现的错误
npm ERR! Linux 4.4.0-62-generic
npm ERR! argv "/usr/local/bin/node" "/usr/bin/npm" "start"
npm ERR! node v7.4.0
npm ERR! npm v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactapp@1.0.0 start: `webpack-dev-server --port 7000 --hot`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactapp@1.0.0 start script 'webpack-dev-server --port 7000 --hot'.
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 reactapp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack-dev-server --port 7000 --hot
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs reactapp
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls reactapp
npm ERR! There is likely additional logging output above.

这是package.json

{
"name": "reactapp",
"version": "1.0.0",
"description": "demo app",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server --port 7000 --hot"
},
"author": "david",
"license": "ISC",
"dependencies": {
"react": "^15.4.2",
"react-dom": "^15.4.2",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.4.1"
}
}

这是 webpack.config.js

var config = {
entry: './main.js',

output: {
path:'./',
filename: 'index.js',
},

devServer: {
inline: true,
port: 7000,

},

module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel',

query: {
presets: ['es2015', 'react']
}
}
]
}
}

module.exports = config;

有人可以帮忙吗?

最佳答案

缺少需要执行的命令之一..请执行以下命令进行安装,

npm install –save-dev webpack-dev-server webpack

虽然他们提到安装 webpack 服务器,但缺少一些命令行参数

关于node.js - 尝试创建 React App 时出现 web pack 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42360632/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com