找不到模块(webpack + vue)

时间:2017-09-18 10:07:31

标签: webpack vuejs2

使用webpack + vue构建项目,webpack包总是提示错误,请参阅代码。

G:\test\webpack_vue>webpack
Hash: 3a2915ed9e32c621ed2c
Version: webpack 3.6.0
Time: 608ms
   Asset    Size  Chunks             Chunk Names
build.js  208 kB       0  [emitted]  main
   [0] ./src/main.js 133 bytes {0} [built]
   [3] (webpack)/buildin/global.js 509 bytes {0} [built]
    + 2 hidden modules

ERROR in ./src/main.js
Module not found: Error: Can't resolve 'vue-loader' in 'G:\test\webpack_vue'
 @ ./src/main.js 4:0-28

所以我重新安装了所有模块,结果仍然提示错误,详情请看代码。

G:\test\webpack_vue>npm install --save-dev babel-core babel-loader babel-plugin-
transform-runtime babel-preset-es2015 babel-runtime css-loader vue-hot-reload-ap
i vue-html-loader vue-style-loader vue-loader
npm WARN deprecated babel-preset-es2015@6.24.1: We're super �  excited that you'
re trying to use ES2015 syntax, but instead of making more yearly presets � , Ba
bel now has a better preset that we recommend you use instead: npm install babel
-preset-env --save-dev. preset-env without options will compile ES2015+ down to
ES5 just like using all the presets together and thus is more future proof. It a
lso allows you to target specific browsers so that Babel can do less work and yo
u can ship native ES2015+ to user � ! We are also in the process of releasing v7
, so please give http://babeljs.io/blog/2017/09/12/planning-for-7.0 a read and h
elp test it out in beta! Thanks so much for using Babel �, please give us a foll
ow on Twitter @babeljs for news on Babel, join slack.babeljs.io for discussion/d
evelopment and help support the project at opencollective.com/babel
webpack_vue@1.0.0 G:\test\webpack_vue
+-- babel-core@6.26.0
+-- babel-loader@7.1.2
+-- babel-plugin-transform-runtime@6.23.0
+-- babel-preset-es2015@6.24.1
+-- babel-runtime@6.26.0
+-- css-loader@0.28.7
+-- vue-hot-reload-api@2.1.0
+-- vue-html-loader@1.2.4
`-- vue-style-loader@3.0.3

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\ch
okidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@
1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}
)
npm WARN webpack_vue@1.0.0 No description
npm WARN webpack_vue@1.0.0 No repository field.
npm WARN The package babel-core is included as both a dev and production depende
ncy.
npm WARN The package babel-loader is included as both a dev and production depen
dency.
npm ERR! path G:\test\webpack_vue\node_modules\js-beautify\js\bin\css-beautify.j
s
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod 'G:\test\webpack_vue\no
de_modules\js-beautify\js\bin\css-beautify.js'
npm ERR! enoent ENOENT: no such file or directory, chmod 'G:\test\webpack_vue\no
de_modules\js-beautify\js\bin\css-beautify.js'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\神盾局\AppData\Roaming\npm-cache\_logs\2017-09-18T09_54_48
_972Z-debug.log

修了两天,仍然没有效果,大家伙帮帮忙,谢谢。

1 个答案:

答案 0 :(得分:0)

这是beatify-web/js-beautify依赖的问题。看看here

作为临时解决方案,您可以在"js-beautify": "1.6.14"文件中添加以下依赖项package.json