2017-10-05 16 views
0

pug.js를 사용해 본 다음 사용하지 않기로 결정했습니다. 내가/lib 디렉토리/consolidate.js를 통합/node_modules에서 다음 줄을 제거하려고, 그래서pug를 제거하는 방법?

Unhandled rejection Error: Cannot find module 'pug' 
    at Function.Module._resolveFilename (module.js:485:15) 
    at Function.Module._load (module.js:437:25) 
    at Module.require (module.js:513:17) 
    at require (internal/module.js:11:18) 
    at /vagrant/myproject/frontend/node_modules/consolidate/lib/consolidate.js:825:33 
    at /vagrant/myproject/frontend/node_modules/consolidate/lib/consolidate.js:144:5 
    at promisify (/vagrant/myproject/frontend/node_modules/consolidate/lib/consolidate.js:137:10) 
    at Function.exports.pug.render (/vagrant/myproject/frontend/node_modules/consolidate/lib/consolidate.js:821:10) 
    at Object.module.exports (/vagrant/myproject/frontend/node_modules/vue-loader/lib/template-compiler/preprocessor.js:26 
:20) 
    at LOADER_EXECUTION (/vagrant/myproject/frontend/node_modules/loader-runner/lib/LoaderRunner.js:119:14) 
    at runSyncOrAsync (/vagrant/myproject/frontend/node_modules/loader-runner/lib/LoaderRunner.js:120:4) 
    at iterateNormalLoaders (/vagrant/myproject/frontend/node_modules/loader-runner/lib/LoaderRunner.js:229:2) 
    at iterateNormalLoaders (/vagrant/myproject/frontend/node_modules/loader-runner/lib/LoaderRunner.js:218:10) 

, 도움이되지 않습니다 :

는 지금은 웹팩, 나는 다음과 같은 오류가 서버가 디바이스를 시작할 때
/** 
* Pug support. (formerly Jade) 
*/ 

exports.pug = function(path, options, fn){ 
    return promisify(fn, function (fn) { 
    var engine = requires.pug; 
    if (!engine) { 
     try { 
     engine = requires.pug = require('pug'); 
     } catch (err) { 
     try { 
      engine = requires.pug = require('then-pug'); 
     } catch (otherError) { 
      throw err; 
     } 
     } 
    } 

    try { 
     var tmpl = cache(options) || cache(options, engine.compileFile(path, options)); 
     fn(null, tmpl(options)); 
    } catch (err) { 
     fn(err); 
    } 
    }); 
}; 

/** 
* Pug string support. 
*/ 

exports.pug.render = function(str, options, fn){ 
    return promisify(fn, function (fn) { 
    var engine = requires.pug; 
    if (!engine) { 
     try { 
     engine = requires.pug = require('pug'); 
     } catch (err) { 
     try { 
      engine = requires.pug = require('then-pug'); 
     } catch (otherError) { 
      throw err; 
     } 
     } 
    } 

    try { 
     var tmpl = cache(options) || cache(options, engine.compile(str, options)); 
     fn(null, tmpl(options)); 
    } catch (err) { 
     fn(err); 
    } 
    }); 
}; 

webpack.base.conf.js :

var path = require('path') 
var utils = require('./utils') 
var config = require('../config') 
var vueLoaderConfig = require('./vue-loader.conf') 

function resolve (dir) { 
    return path.join(__dirname, '..', dir) 
} 

module.exports = { 
    entry: { 
    app: './src/main.js' 
    }, 
    output: { 
    path: config.build.assetsRoot, 
    filename: '[name].js', 
    publicPath: process.env.NODE_ENV === 'production' 
     ? config.build.assetsPublicPath 
     : config.dev.assetsPublicPath 
    }, 
    resolve: { 
    extensions: ['.js', '.vue', '.json'], 
    alias: { 
     'vue$': 'vue/dist/vue.esm.js', 
     '@': resolve('src'), 
    } 
    }, 
    module: { 
    rules: [ 
     { 
     test: /\.(js|vue)$/, 
     loader: 'eslint-loader', 
     enforce: 'pre', 
     include: [resolve('src'), resolve('test')], 
     options: { 
      formatter: require('eslint-friendly-formatter') 
     } 
     }, 
     { 
     test: /\.vue$/, 
     loader: 'vue-loader', 
     options: vueLoaderConfig 
     }, 
     { 
     test: /\.js$/, 
     loader: 'babel-loader', 
     include: [resolve('src'), resolve('test')] 
     }, 
     { 
     test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 
     loader: 'url-loader', 
     options: { 
      limit: 10000, 
      name: utils.assetsPath('img/[name].[hash:7].[ext]') 
     } 
     }, 
     { 
     test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, 
     loader: 'url-loader', 
     options: { 
      limit: 10000, 
      name: utils.assetsPath('media/[name].[hash:7].[ext]') 
     } 
     }, 
     { 
     test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 
     loader: 'url-loader', 
     options: { 
      limit: 10000, 
      name: utils.assetsPath('fonts/[name].[hash:7].[ext]') 
     } 
     } 
    ] 
    } 
} 

webpack.dev.conf.js :

var utils = require('./utils') 
var webpack = require('webpack') 
var config = require('../config') 
var merge = require('webpack-merge') 
var baseWebpackConfig = require('./webpack.base.conf') 
var HtmlWebpackPlugin = require('html-webpack-plugin') 
var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') 

// add hot-reload related code to entry chunks 
Object.keys(baseWebpackConfig.entry).forEach(function (name) { 
    baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name]) 
}) 

module.exports = merge(baseWebpackConfig, { 
    module: { 
    rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap }) 
    }, 
    // cheap-module-eval-source-map is faster for development 
    devtool: '#cheap-module-eval-source-map', 
    plugins: [ 
    new webpack.DefinePlugin({ 
     'process.env': config.dev.env 
    }), 
    // https://github.com/glenjamin/webpack-hot-middleware#installation--usage 
    new webpack.HotModuleReplacementPlugin(), 
    new webpack.NoEmitOnErrorsPlugin(), 
    // https://github.com/ampedandwired/html-webpack-plugin 
    new HtmlWebpackPlugin({ 
     filename: 'index.html', 
     template: 'index.html', 
     inject: true 
    }), 
    new FriendlyErrorsPlugin() 
    ] 
}) 

어디에 구성되어 있는지 찾으십시오. 나는 퍼그와 그 의존성을 제거해야합니다. 감사합니다. .

+0

웹팩 설정은 무엇입니까? 일부 충전기가 여전히 pug를 참조 할 가능성이 있습니까? – Axnyff

+0

예, 가능하지만 표시되지 않습니다. 내 질문에 webpack 구성을 추가했습니다. – theodor

+0

vue conf에 pug 나 jade와 관련된 것이 있습니까? vue 구성 요소에 옥/퍼그 템플릿이 있습니까? – Axnyff

답변

0

@Axnyff 덕분에 필자는 내 Vue 구성 요소 중 하나에서 템플릿 lang = "pug"를 삭제하지 않은 것을 발견했습니다.