有谁能解释一下,为什么我在npm start之后收到这个警告?
这是我的package.json
{
"name": "rou-lesson",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "5.0.0",
"web-vitals": "^2.1.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
这里有一个来自webpack的警告,在npm启动后我一直收到这个消息。
enter image description here
npm启动后
您现在可以在浏览器中查看rou-lesson。
本地:http://localhost:3000
在您的网络上:http://192.168.0.103:3000
请注意,开发版本没有优化。要创建生产构建,请使用npm run build。
> assets by path static/ 1.52 MiB asset static/js/bundle.js 1.51 MiB
> [emitted] (name: main) 1 rela asset
> static/js/node_modules_web-vitals_dist_web-vitals_js.chunk asset
> static/media/logo.6ce24c58023cc2f8fd88fe9d219db6c6.svg 2.5 asset
> index.html 1.67 KiB [emitted] asset asset-manifest.json 546 bytes
> [emitted] runtime modules 31.4 KiB 16 modules modules by path
> ./node_modules/ 1.38 MiB 95 modules modules by path ./src/ 18.1 KiB
> modules by path ./src/*.css 8.82 KiB
> ./src/index.css 2.72 KiB [built] [code generated]
> ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].ones??ruleSet[1].rules[1].oneOf[5].use[2]!./node_modules/source-map-lode
> generated]
> ./src/App.css 2.72 KiB [built] [code generated]
> ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].ones??ruleSet[1].rules[1].oneOf[5].use[2]!./node_modules/source-map-lenerated]
> modules by path ./src/*.js 5.71 KiB KiB [built] [code generated]
> webpack 5.65.0 compiled successfully in 12201 ms
1条答案
按热度按时间mcvgt66p1#
当您在命令行中键入“npm starts”时,webpack会以“开发”模式运行您的代码,这意味着webpack不会优化您的代码并在内存中运行它以更快地运行(它不会将优化的文件作为“开发模式”中的结果)。当你以“生产”模式运行时,Webpack会优化你的文件。如果你输入“npm run build”,webpack会优化你所有的代码,并将其作为一个rusult捆绑文件。我认为该消息只是webpack抛出的一个警告消息,以自动提醒用户这一点