我在 C:/ Users / user / AppData / Roaming / npm / node_modules 路径中有所有节点模块。然后我尝试将包含babel和babel-presets的node_modules包含在我的脚本webpack中。
我的 webpack.config.js
module.exports = {
context: './scripts',
entry: ['./main', './2.jsx'],
output: {
path: '../scripts',
filename: 'bundle.js',
},
resolve: {
modulesDirectories: ['C:/Users/user/AppData/Roaming/npm/node_modules']
},
resolveLoader: {
root: 'C:/Users/user/AppData/Roaming/npm/node_modules'
},
module: {
loaders: [{
test: /\.jsx?$/,
loader: 'babel-loader',
include: 'C:/Users/user/AppData/Roaming/npm/node_modules',
exclude: /(node_modules|bower_components)/,
query: {
presets: ['es2015', 'react']
}
}],
},
};
但是babel没有看到预设 es2015 。并预设了反应我也想。
webpack
命令重新调整:
ERROR in ../main.js Module build failed: Error: Couldn't find preset "es2015"
at OptionManager.mergePresets (C:\Users\user\AppData\Roaming\npm\node_modules\babel-core\lib\transformation\file\options\option-manager.js:329:17)
at OptionManager.mergeOptions (C:\Users\user\AppData\Roaming\npm\node_modules\babel-core\lib\transformation\file\options\option-manager.js:289:12)
at OptionManager.init (C:\Users\user\AppData\Roaming\npm\node_modules\babel-core\lib\transformation\file\options\option-manager.js:414:10)
at File.initOptions (C:\Users\user\AppData\Roaming\npm\node_modules\babel-core\lib\transformation\file\index.js:191:75)
at new File (C:\Users\user\AppData\Roaming\npm\node_modules\babel-core\lib\transformation\file\index.js:122:22)
at Pipeline.transform (C:\Users\user\AppData\Roaming\npm\node_modules\babel-core\lib\transformation\pipeline.js:42:16)
at transpile (C:\Users\user\AppData\Roaming\npm\node_modules\babel-loader\index.js:14:22)
at Object.module.exports (C:\Users\user\AppData\Roaming\npm\node_modules\babel-loader\index.js:83:14) @ multi main
请帮助。错误在哪里?
答案 0 :(得分:1)
找到解决方案。
npm link <pkg>
添加了模块链接。