webpack中配置modules后页面报错没安装依赖,但是这些依赖我都已经安装了,package.json中有配置信息。
报错信息如下:
These dependencies were not found:
* ansi-html in (webpack)-dev-server/client/overlay.js
* axios in ./src/main.js
* html-entities in (webpack)-dev-server/client/overlay.js
* lodash in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/components/lodash.vue
* loglevel in (webpack)-dev-server/client?http://localhost:8080
* sockjs-client/dist/sockjs in (webpack)-dev-server/client/socket.js
* strip-ansi in (webpack)-dev-server/client?http://localhost:8080
* vue in ./src/App.vue, ./src/main.js and 5 others
* vue-hot-reload-api in ./src/App.vue, ./node_modules/vue-loader/lib/template-compiler?{"id":"data-v-7ba5bd90","hasScoped":false,"transformToRequire":{"video":["src","poster"],"source":"src","img":"src","image":"xlink:href"},"buble":{"transforms":{}}}!./node_modules/vue-loader/lib/selector.js?type=template&index=0!./src/App.vue and 8 others
* vue-router in ./src/router/index.js
* webpack/hot in (webpack)-dev-server/client?http://localhost:8080
* webpack/hot/dev-server in multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js
* webpack/hot/emitter in (webpack)-dev-server/client?http://localhost:8080
To install them, you can run: npm install --save ansi-html axios html-entities lodash loglevel sockjs-client/dist/sockjs strip-ansi vue vue-hot-reload-api vue-router webpack/hot webpack/hot/dev-server webpack/hot/emitter
添加的webpack配置如下:
resolve: {
modules: ['src', 'src/components'].map(resolve)
}
把这段modules配置去掉就不报错了。
加上
node_modules
吧