webpack打包问题

webpack打包问题

打包过程中发现总是package.json里面的版本导致打包失败,npm的时候怎么才能找到合适的版本吗,难道只能打包错误的时候再一个个试版本吗

{

"name": "lesson",

"version": "1.0.0",

"description": "",

"main": "index.js",

"scripts": {

"start": "webpack-dev-server"

},

"author": "Zhe Wang",

"license": "ISC",

"devDependencies": {

"@babel/core": "^7.2.0",

"@babel/plugin-transform-runtime": "^7.2.0",

"@babel/preset-env": "^7.2.0",

"@babel/preset-react": "^7.14.5",

"@types/autoprefixer": "^10.2.0",

"autoprefixer": "^9.7.2",

"babel-loader": "^8.0.4",

"clean-webpack-plugin": "^3.0.0",

"css-loader": "^1.0.1",

"express": "^4.17.1",

"file-loader": "^6.2.0",

"html-webpack-plugin": "^4.5.0",

"node-sass": "^4.10.0",

"postcss-loader": "^3.0.0",

"sass-loader": "^7.1.0",

"style-loader": "^0.23.1",

"url-loader": "^4.1.1",

"webpack": "^4.46.0",

"webpack-cli": "^3.3.12",

"webpack-dev-middleware": "^5.0.0",

"webpack-dev-server": "3.11.2"

},

"dependencies": {

"@babel/polyfill": "^7.0.0",

"@babel/runtime": "^7.2.0",

"@babel/runtime-corejs2": "^7.2.0",

"react": "^17.0.2",

"react-dom": "^17.0.2"

}

}


回答:

先看看你的node版本,再看看包依赖哪个node的版本,如果因为node版本过低,就更新node版本。如果不想更新,就只能降低包的版本


回答:

npm install的时候有没有package-lock.json文件,如果只有package.json文件而且没有直接指定版本,版本出错很正常

以上是 webpack打包问题 的全部内容, 来源链接: utcz.com/p/936045.html

回到顶部