gpt4 book ai didi

node.js - NPM Start 不启动本地服务器

转载 作者:搜寻专家 更新时间:2023-10-31 23:46:21 24 4
gpt4 key购买 nike

我正在尝试使用 webpack 制作一个 React 应用程序,当我尝试运行 npm start 它应该加载 http://localhost:3333 但它说无法访问网站,这是我的 webpack配置:

module.exports = {
entry: './main.js',
output: {
path: '/',
filename: 'index.js'
},
devServer: {
inline: true,
port: 3333
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015', 'react']
}
}
]
}
}

这是来自 package.json 的脚本对象:"start": "webpack-dev-server"。我已经在全局范围内安装了 webpack 和 webpack-dev-server。检查下面我得到的图像: enter image description here

编辑:我的 package.json:

{
"name": "react-app",
"version": "1.0.0",
"description": "sample",
"scripts": {
"start": "webpack-dev-server"
},
"repository": {
"type": "git",
"url": "git+https://github.com/dheeraja00/react-app.git"
},
"author": "Dheeraj Agrawal",
"license": "ISC",
"bugs": {
"url": "https://github.com/dheeraja00/react-app/issues"
},
"homepage": "https://github.comdheeraja00/react-app#readme",
"dependencies": {
"material-design-lite": "^1.2.1",
"react": "^15.3.2"
},
"devDependencies": {
"babel-core": "^6.18.0",
"babel-loader": "^6.2.5",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"css-loader": "^0.25.0",
"file-loader": "^0.9.0",
"node-sass": "^3.10.1",
"raw-loader": "^0.5.1",
"sass-loader": "^4.0.2",
"style-loader": "^0.13.1",
"webpack": "^1.13.2",
"webpack-dev-server": "^1.16.2"
}
}

最佳答案

您可以运行以下任一命令来为您的 reactJs 应用程序启动 Node 服务器:

 npm run-script start
npm run start
npm start

关于node.js - NPM Start 不启动本地服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40478608/

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