0
私はpug.jsを試した後、それを使用しないようにしてアンインストールしました。私はWebPACKのdevのサーバーを起動したとき は今、私は次のエラーを取得する: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)
、私は/ libに/ consolidate.jsを統合/ node_modulesから次の行を削除しようとした、それは助けにはならない。
/**
* 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()
]
})
どこに設定されているかを確認してください。私はpugとその依存関係を取り除く必要があります。おかげさまで
あなたのウェブパックの設定は何ですか?もしローダーの中にはまだpugを参照している可能性はありますか? – Axnyff
はい、可能ですが、私はそれを見ません。私は私の質問にwebpackの設定を追加しました。 – theodor
vue confにpugやjadeに関するものはありますか?どのvueコンポーネントにもjade/pugテンプレートがありますか? – Axnyff