go-bbs 学习 安装前端的时候报错: ERROR Cannot find module ‘vue-template-compiler‘

go-bbs 学习

1:之前第一步安装的时候 跟着文档没有问题 当时的Node环境是16  

1.重装系统后  下载的16.19.0版本 报以上的错误:

2.解决办法:

npm i  vue-template-compiler


或者
cnpm i  vue-template-compiler

疑惑:好像使用 npm install   vue-template-compiler  在运行项目还是会报错。

// 第一次安装  添加了3个包。
PS D:\Golang Project\bbs-go\site> npm i -g vue-template-compiler 

added 3 packages, and audited 5 packages in 5s

found 0 vulnerabilities
PS D:\Golang Project\bbs-go\site> npm run dev

> [email protected] dev
> nuxt


 WARN  [email protected] is installed but ^10.1.1 is expected                                                                                                             17:33:41  

ℹ [HPM] Proxy created: /api/  -> http://127.0.0.1:8082                                                                                                                   17:33:42

   ╭───────────────────────────────────────╮
   │                                       │
   │   Nuxt @ v2.17.2                      │
   │                                       │
   │   ▸ Environment: development          │
   │   ▸ Rendering:   server-side          │
   │   ▸ Target:      server               │
   │                                       │
   │   Listening: http://localhost:3000/   │
   │                                       │
   ╰───────────────────────────────────────╯

ℹ Preparing project for development                                                                                                                                      17:33:44
ℹ Initial build may take a while                                                                                                                                         17:33:44
ℹ Discovered Components: .nuxt/components/readme.md                                                                                                                      17:33:44
✔ Builder initialized                                                                                                                                                    17:33:44
✔ Nuxt files generated                                                                                                                                                   17:33:44

 ERROR  Cannot find module 'vue-template-compiler'                                                                                                                        17:33:46  
Require stack:
- D:\Golang Project\bbs-go\site\node_modules\.store\[email protected]\node_modules\vue-loader\lib\compiler.js
- D:\Golang Project\bbs-go\site\node_modules\.store\[email protected]\node_modules\vue-loader\lib\resolveScript.js
- D:\Golang Project\bbs-go\site\node_modules\.store\[email protected]\node_modules\vue-loader\lib\select.js
- D:\Golang Project\bbs-go\site\node_modules\.store\[email protected]\node_modules\vue-loader\lib\index.js
- D:\Golang Project\bbs-go\site\node_modules\.store\@[email protected]\node_modules\@nuxt\webpack\dist\webpack.js
- D:\Golang Project\bbs-go\site\node_modules\.store\@[email protected]\node_modules\@nuxt\builder\dist\builder.js
- D:\Golang Project\bbs-go\site\index.js

  Require stack:
  - node_modules\.store\[email protected]\node_modules\vue-loader\lib\compiler.js
  - node_modules\.store\[email protected]\node_modules\vue-loader\lib\resolveScript.js
  - node_modules\.store\[email protected]\node_modules\vue-loader\lib\select.js
  - node_modules\.store\[email protected]\node_modules\vue-loader\lib\index.js
  - node_modules\.store\@[email protected]\node_modules\@nuxt\webpack\dist\webpack.js
  - node_modules\.store\@[email protected]\node_modules\@nuxt\builder\dist\builder.js
  - index.js
  at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
  at Function.resolve (node:internal/modules/cjs/helpers:108:19)
  at loadFromContext (node_modules\.store\[email protected]\node_modules\vue-loader\lib\compiler.js:30:26)
  at loadTemplateCompiler (node_modules\.store\[email protected]\node_modules\vue-loader\lib\compiler.js:37:12)
  at exports.resolveCompiler (node_modules\.store\[email protected]\node_modules\vue-loader\lib\compiler.js:25:23)
  at VueLoaderPlugin.apply (node_modules\.store\[email protected]\node_modules\vue-loader\lib\plugin-webpack4.js:91:22)
  at VueLoaderPlugin.apply (node_modules\.store\[email protected]\node_modules\vue-loader\lib\plugin.js:13:16)
  at node_modules\.store\@[email protected]\node_modules\@nuxt\webpack\dist\webpack.js:1821:24
  at Array.map ()
  at WebpackBundler.build (node_modules\.store\@[email protected]\node_modules\@nuxt\webpack\dist\webpack.js:1820:37)
  at async Builder.build (node_modules\.store\@[email protected]\node_modules\@nuxt\builder\dist\builder.js:249:5)
  at async Object._buildDev (node_modules\.store\@[email protected]\node_modules\@nuxt\cli\dist\cli-dev.js:79:5)
  at async Object.startDev (node_modules\.store\@[email protected]\node_modules\@nuxt\cli\dist\cli-dev.js:55:7)
  at async Object.run (node_modules\.store\@[email protected]\node_modules\@nuxt\cli\dist\cli-dev.js:44:5)

成功的例子:

PS D:\Golang Project\bbs-go\site> cnpm i  vue-template-compiler
√ Linked 1 latest versions fallback to D:\Golang Project\bbs-go\site\node_modules\.store\node_modules
√ Installed 1 packages on D:\Golang Project\bbs-go\site
√ All packages installed (used 168ms(network 164ms), speed 0B/s, json 0(0B), tarball 0B, manifests cache hit 1, etag hit 1 / miss 0)

dependencies:
+ vue-template-compiler ^2.7.15
  //展示了依赖

总结:

使用  npm i -g vue-template-compiler  显示添加了3个包 。但不一定会成功安装依赖!

成功安装依赖如上图: 展示出来 。然后运行就没有问题。

你可能感兴趣的:(前端,学习,vue.js)