Vue-cli: [vue build] Issue installing stylus-loader, 'webpack' not found

Created on 8 May 2017  路  3Comments  路  Source: vuejs/vue-cli

Using the vue build command without configuration, I can't make stylus to work without installing webpack or I will get an error that the module resolver can't find it:

Module build failed: Error: Cannot find module 'webpack'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/akryum/Projets/packt-vue-project-guide/chapter4/node_modules/stylus-loader/index.js:181:27)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at loadLoader (/usr/local/lib/node_modules/vue-cli/node_modules/loader-runner/lib/loadLoader.js:13:17)
    at iteratePitchingLoaders (/usr/local/lib/node_modules/vue-cli/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/usr/local/lib/node_modules/vue-cli/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /usr/local/lib/node_modules/vue-cli/node_modules/loader-runner/lib/LoaderRunner.js:173:18

 @ /usr/local/lib/~/vue-cli/~/vue-style-loader!/usr/local/lib/~/vue-cli/~/css-loader?-autoprefixer&sourceMap!/usr/local/lib/~/vue-cli/~/vue-loader/lib/style-rewriter.js?id=data-v-0ba4de5c&scoped=true!/usr/local/lib/~/vue-cli/~/postcss-loader?sourceMap!./~/stylus-loader?sourceMap!/usr/local/lib/~/vue-cli/~/vue-loader/lib/selector.js?type=styles&index=0!./Stylus.vue 4:14-528 13:3-17:5 14:22-536
 @ ./Stylus.vue
 @ /usr/local/lib/~/vue-cli/lib/default-entry.es6
 @ multi (webpack)-hot-middleware/client.js?reload=true /usr/local/lib/~/vue-cli/lib/default-entry.es6

What I expect

npm install --save-dev stylus stylus-loader

What I have to do

npm install --save-dev stylus stylus-loader webpack

Most helpful comment

stylus-loader requires webpack as a peer dependency so nothing we could do here, you solution would work but I always install vue-cli as devDependency instead.

All 3 comments

stylus-loader requires webpack as a peer dependency so nothing we could do here, you solution would work but I always install vue-cli as devDependency instead.

Maybe we should recommend in the doc to install vue-cli locally to prevent issues with stylus or pug.

You can also go to ~/.vue and install it there yarn add webpack stylus. The global vue will load those packages

Was this page helpful?
0 / 5 - 0 ratings