2
votes

I have all node modules in C:/Users/user/AppData/Roaming/npm/node_modules path. Then I'm trying include node_modules with babel and babel-presets for my scripts webpack.

My 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']
            }
        }],
    },
};

But babel does not see preset es2015. And preset react I think too.

The webpack command retunrs this:

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

Help please. Where is the mistake?

1
Why don't you add them to your project in local ? npm install XXXX --save-dev ?Arnaud Gueras
Im trying to find solution with many projects with one node_modules folderIfgeny87
It's not the right way, each node project should have it's own node_modules folder, and all modules are declared into the package.json file.Arnaud Gueras
the whole point of npm and modules is so each project can have its own dependencies.webduvet

1 Answers

1
votes

Found solution.

npm link <pkg>

Its added links to modules.