简体   繁体   English

找不到Webpack模块:错误:无法解析模块'imagesLoaded'

[英]Webpack module not found: Error: Cannot resolve module 'imagesLoaded'

I am trying to include sequence.js in my index.js file and I get the following error: 我试图在我的index.js文件中包含sequence.js,但出现以下错误:

ERROR in ./src/js/sequence.js Module not found: Error: Cannot resolve module 'imagesLoaded' in /home/jdellaria/Desktop/Musicpack/src/js @ ./src/js/sequence.js 1144:95-143 ./src/js/sequence.js中的错误未找到模块:错误:无法解析/ home / jdellaria / Desktop / Musicpack / src / js @ ./src/js/sequence.js 1144:95-中的模块“ imagesLoaded” 143

ERROR in ./src/js/sequence.js Module not found: Error: Cannot resolve module 'Hammer' in /home/jdellaria/Desktop/Musicpack/src/js @ ./src/js/sequence.js 1144:95-143 Here is my Configuration ./src/js/sequence.js中的错误找不到模块:错误:无法解析/ home / jdellaria / Desktop / Musicpack / src / js @ ./src/js/sequence.js 1144:95-中的模块'Hammer' 143这是我的配置

webpack.config.js webpack.config.js

// var webpack = require('webpack');
var path = require('path');
// webpack.config.js
var config = {
    entry: './src',
     resolve: {
      root: path.resolve('./src'),
      extenstions: ['', '.js'],
      moduleDirectories: ['node_modules']
    },
    output: {
        path: './dist',
        filename: 'my-app.js'
    },
    externals:[
        require('webpack-require-http')
    ],
    module: 
    {
      loaders: 
      [
       { test: /\.css$/, loaders: ['style', 'css'] }, // Note that the order is important here, it means that 'style-loader' will be applied to the ouput of 'css-loader'
    { test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/, query: {presets: ['es2015']}},
//        { test: /\.js$/, loaders: ['babel']  },     // note that specifying 'babel' or 'babel-loader' is equivalent for Webpack
    { test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,  loader: "url-loader?limit=10000&minetype=application/font-woff" },
    { test: /\.(jpe?g|png|gif|svg)$/, loader: 'url-loader?limit=10000&name=[path][name].[ext]'},
    { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" }

  ]
}
}
module.exports = config;

index.js index.js

require("!style!css!./css/styley.css");
require("./js/sequence.js");

console.log('Hello Webpack!');
document.write("It works.");
var greet = require('./greet');   // Import the greet function
greet('Webpack Jon');

index.html index.html

<html>
    <head>
    <script type="text/javascript" src="./dist/my-app.js"></script>
    </head>
    <body>
    </body>
</html>

Sequence.js uses AMD modules, and its looking to resolve those in the node_modules directory. Sequence.js使用AMD模块,它的目的是解决node_modules目录中的模块。 Instead of referencing script directly in the /js folder, install it as a node module: 与其直接在/ js文件夹中引用脚本,不如将其安装为节点模块:

npm install sequencejs

Then require it like this in your index.js 然后在index.js中要求这样

require("sequencejs");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM