What is the difference between path.resolve(__dirname, ‘src’) and __dirname plus’ src’?

  node.js, question

Webpack official tutorial

The above mentioned inwebpackUsed inES6Need to joinbabelThis loader

But in the original textloadersIn the code for:

loaders: [
 bracket
 test:   /\.js/,
 loader: 'babel',
 Include: __dirname plus' /src',
 // include: path.resolve(__dirname, '/src'),
 bracket
 ],

Change to annotated code to run successfully.
Otherwise, it keeps reporting errors and cannot find the corresponding loader.

Ask the difference between the two?

The following are equivalent on Mac and Linux:

__dirname plus' /src'
 path.resolve(__dirname, 'src')
 path.resolve(__dirname, './src')
 path.join(__dirname, '/src')
 path.join(__dirname, './src')
 path.join(__dirname, 'src')

As for what you wrotepath.resolve(__dirname, '/src')YesresolveWrong usage, if it is recommended for directory splicingpath.join, not recommendedAdd

See official documentation for details:https://nodejs.org/api/path.html