欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

npm run dev 报错 Module build failed: Error: Cannot find module 'prettier'

程序员文章站 2022-06-05 09:14:30
...

VUE环境搭建前几步骤可以看博客

报错信息如下:

PS H:\UI\VUE\my-project-first> npm run dev

> aaa@qq.com dev H:\UI\VUE\my-project-first
> webpack-dev-server --inline --progress --config build/webpack.dev.conf.js

 94% asset optimization

 ERROR  Failed to compile with 2 errors                                                                         08:56:42

 error  in ./src/App.vue

Module build failed: Error: Cannot find module 'prettier'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (H:\UI\VUE\my-project-first\node_modules\aaa@qq.com@vue-loader\lib\template-compiler\index.js:1:80)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at loadLoader (H:\UI\VUE\my-project-first\node_modules\aaa@qq.com@loader-runner\lib\loadLoader.js:18:17)
    at iteratePitchingLoaders (H:\UI\VUE\my-project-first\node_modules\aaa@qq.com@loader-runner\lib\LoaderRunner.js:169:2)
    at runLoaders (H:\UI\VUE\my-project-first\node_modules\aaa@qq.com@loader-runner\lib\LoaderRunner.js:365:2)
    at NormalModule.doBuild (H:\UI\VUE\my-project-first\node_modules\aaa@qq.com@webpack\lib\NormalModule.js:182:3)

 @ ./src/App.vue 11:0-392
 @ ./src/main.js
 @ multi ./node_modules/aaa@qq.com@webpack-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js

 error  in ./src/components/HelloWorld.vue

Module build failed: Error: Cannot find module 'prettier'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (H:\UI\VUE\my-project-first\node_modules\aaa@qq.com@vue-loader\lib\template-compiler\index.js:1:80)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at loadLoader (H:\UI\VUE\my-project-first\node_modules\aaa@qq.com@loader-runner\lib\loadLoader.js:18:17)
    at iteratePitchingLoaders (H:\UI\VUE\my-project-first\node_modules\aaa@qq.com@loader-runner\lib\LoaderRunner.js:169:2)
    at runLoaders (H:\UI\VUE\my-project-first\node_modules\aaa@qq.com@loader-runner\lib\LoaderRunner.js:365:2)
    at NormalModule.doBuild (H:\UI\VUE\my-project-first\node_modules\aaa@qq.com@webpack\lib\NormalModule.js:182:3)

 @ ./src/components/HelloWorld.vue 11:0-404
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi ./node_modules/aaa@qq.com@webpack-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js

可以参看链接,我直接在项目下,对prettier模块进行安装,

PS H:\UI\VUE\my-project-first> cnpm install prettier
√ Installed 1 packages
√ Linked 0 latest versions
√ Run 0 scripts
√ All packages installed (1 packages installed from npm registry, used 1s(network 1s), speed 1.38MB/s, json 1(7.65kB), tarball 1.94MB)

 

再输入npm run dev

PS H:\UI\VUE\my-project-first> npm run dev

> aaa@qq.com dev H:\UI\VUE\my-project-first
> webpack-dev-server --inline --progress --config build/webpack.dev.conf.js

 13% building modules 32/37 modules 5 active ...t-first\src\components\HelloWorld.vue{ parser: "babylon" } is deprecated; we now treat it as { parser: "bab 95% emitting

 DONE  Compiled successfully in 3615ms                                                                          08:57:18

 I  Your application is running here: http://localhost:8080

在浏览器中打开,http://localhost:8080即可看到页面来了。

npm run dev 报错 Module build failed: Error: Cannot find module 'prettier'