ERROR in ./src/js/modules/header/index.jsx
Module not found: Error: Cannot resolve module 'index.less' in C:/Users/Desktop/src/js/modules/header
@ ./src/js/modules/header/index.jsx 5:0-21
ERROR in ./src/js/modules/header/index.less
Module not found: Error: Cannot resolve 'file' or 'directory' ./../../../../node_modules/css-loader/index.js in C:/Users/Desktop/src/js/modules/header
@ ./src/js/modules/header/index.less 4:14-134
ERROR in ./src/js/modules/header/index.less
Module not found: Error: Cannot resolve 'file' or 'directory' ./../../../../node_modules/style-loader/addStyles.js in C:/Users/Desktop/src/js/modules/header
@ ./src/js/modules/header/index.less 7:13-77
var path = require('path'); module.exports = { context: path.join(__dirname, 'src'), resolve: { root: path.resolve(__dirname, "src"), // root: __dirname + '/src', } }
两者的不同,可看一下输出
console.log(path.resolve(__dirname, "src")); // 输出: C:/Users/joeyguo/Desktop/src console.log(__dirname + '/src'); // 输出: C:/Users/joeyguo/Desktop/src
ERROR in Cannot find module 'less'
@ ./src/js/modules/header/index.less 4:14-134
npm install less less-loader --save-dev