网上找个例子,运行的时候各种冲突,各种报错,折腾了快一天都没跑起来。直到遇到了神奇的npm install --legacy-peer-deps 指令才成功。记录如下:
C:\workspace\vue2-happyfri>npm install
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/less
npm ERR! dev less@"^3.9.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer less@"^2.3.1" from [email protected]
npm ERR! node_modules/less-loader
npm ERR! dev less-loader@"^2.2.3" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Administrator\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Local\npm-cache\_logs\2022-08-26T08_32_12_224Z-debug-0.log
C:\workspace\vue2-happyfri>npm install --legacy-peer-deps
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm WARN deprecated [email protected]: Please use postcss-loader instead of autoprefixer-loader
npm WARN deprecated [email protected]: Thanks for using Babel: we recommend using babel-preset-env now: please read https://babeljs.io/env to update!
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated [email protected]: flatten is deprecated in favor of utility frameworks such as lodash.
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated [email protected]: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: Deprecated. Please use https://github.com/webpack-contrib/mini-css-extract-plugin
npm WARN deprecated [email protected]: out of support
npm WARN deprecated [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm WARN deprecated [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
added 911 packages, and audited 912 packages in 1m
42 packages are looking for funding
run `npm fund` for details
60 vulnerabilities (3 low, 43 moderate, 12 high, 2 critical)
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
C:\workspace\vue2-happyfri>npm run serve
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! Missing script: "serve"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Local\npm-cache\_logs\2022-08-26T08_35_27_312Z-debug-0.log
C:\workspace\vue2-happyfri>npm run dev
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
> [email protected] dev
> node build/dev-server.js
Listening at http://localhost:8088
webpack built 2f6e185a6aaba8bf329d in 2690ms
Hash: 2f6e185a6aaba8bf329d
Version: webpack 1.15.0
Time: 2690ms
Asset Size Chunks Chunk Names
static/img/1-2.png 21.3 kB [emitted]
static/img/1-4.png 2.09 kB [emitted]
static/img/2-1.png 4.95 kB [emitted]
static/img/2-2.png 2.16 kB [emitted]
static/img/3-1.png 2.46 kB [emitted]
static/img/WechatIMG2.png 1.75 kB [emitted]
static/img/1-1.jpg 111 kB [emitted]
static/img/4-1.jpg 130 kB [emitted]
static/img/4-2.png 11.2 kB [emitted]
static/img/4-3.png 4.19 kB [emitted]
static/img/4-4.png 3.98 kB [emitted]
static/img/5-1.png 209 bytes [emitted]
static/img/5-2.png 6.24 kB [emitted]
app.js 2.09 MB 0 [emitted] app
1.item.js 57.1 kB 1 [emitted] item
2.home.js 57.3 kB 2 [emitted] home
3.score.js 31 kB 3 [emitted] score
index.html 674 bytes [emitted]
Child html-webpack-plugin for "index.html":
Asset Size Chunks Chunk Names
index.html 1.48 MB 0
webpack: Compiled successfully.