node.js - 如何使用 npm run serve 解决错误
问题描述
我是 Vue 的新手。我已经成功创建了一段时间的项目,没有任何问题。然而,今天我创建了一个新项目,当我尝试“npm run serve”时,我突然得到了三个错误。即使是服务良好的旧项目,我也无法再次为他们服务
我使用的是 Windows 7,所以节点版本是 13.14.0 这是我得到的错误: ERROR Failed to compile with 3 errors
10:46:02 PM
ERROR Failed to compile with 3 errors
10:46:02 PM
These dependencies were not found:
* C:\Users\hp\Documents\vue full learn\dojo-blog-
composition\node_modules\webpack-dev-server\client\index.js?
http://192.168.43.35:8081&sockPath=/sockjs-node in multi
(webpack)-dev-server/client?
http://192.168.43.35:8081&sockPath=/sockjs-node
(webpack)/hot/dev-server.js ./src/main.js
* C:\Users\hp\Documents\vue full learn\dojo-blog-
composition\node_modules\webpack\hot\dev-server.js in multi
(webpack)-dev-server/client?
http://192.168.43.35:8081&sockPath=/sockjs-node
(webpack)/hot/dev-server.js ./src/main.js
To install them, you can run: npm install --save
C:\Users\hp\Documents\vue full learn\dojo-blog-
composition\node_modules\webpack-dev-
server\client\index.js?
http://192.168.43.35:8081&sockPath=/sockjs-node
C:\Users\hp\Documents\vue full learn\dojo-blog-
composition\node_modules\webpack\hot\dev-server.js
This relative module was not found:
* ./src/main.js in multi (webpack)-dev-server/client?
http://192.168.43.35:8081&sockPath=/sockjs-node
(webpack)/hot/dev-server.js ./src/main.js
我检查了 webpack-dev-server 在 node-bundles 文件夹中。当我尝试按照上面的指示进行安装时,出现了更多错误:
npm ERR! code ENOLOCAL
npm ERR! Could not install from "..\..\..\Documents\vue" as it
does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\hp\AppData\Roaming\npm-
cache\_logs\2021-01-02T22_03_20_183Z-debug.log
'sockPath' is not recognized as an internal or external command,
operable program or batch file.
这是 package.json
{
"name": "project-planner",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
},
"dependencies": {
"core-js": "^3.6.5",
"vue": "^3.0.0",
"vue-router": "^4.0.0-0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.0",
"webpack-dev-server": "^3.11.2"
}
}
我用 npm install 得到了这个
npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
> core-js@3.8.3 postinstall C:\Users\hp\My Documents\webdev\projects\learnVue\project-planner\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock
Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
> ejs@2.7.4 postinstall C:\Users\hp\My Documents\webdev\projects\learnVue\project-planner\node_modules\ejs
> node ./postinstall.js
Thank you for installing EJS: built with the Jake JavaScript build tool (https://jakejs.com/)
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.1 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"ia32"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\watchpack-chokidar2\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"ia32"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\webpack-dev-server\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"ia32"})
added 1214 packages from 934 contributors and audited 1217 packages in 527.888s
61 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
解决方案
推荐阅读
- excel - 有条件地转置excel数据
- javascript - 为什么 nuxt 内容获取方法不起作用?
- sql - 使用 JOIN 生成语法错误的 UNION ALL 子查询
- dpdk - 缺少 DPDK UDP 数据包有效负载
- c++ - 使用 std::string::c_str() 修改底层 std::string 是否安全?
- html - 我不明白为什么 HTML 表单不符合要求
- python - 在 Python 中显示菱形
- reactjs - 提交后重置 React-Select (Unform)
- python - 将多个 swagger 文档(来自不同应用程序)合并到一个 swagger 仪表板 [drf_yasg]
- prolog - Prolog - 数字列表的数字