babel-plugin-module-resolver (^3.2.0) does not work inside node_modules in babel 7Babel module build failed when passing multiple presets into create-react app package.jsonwebpack context and resolve.modules not resolving node_modulesBabel-loader 8 complains about not finding deprecated babel-preset-es2015Webpack cannot identify my JSX syntax inside my js fileModule build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module 'babel-preset-react'How to transpile node_modules modules with babel-loader?How to include a few node_modules package in babel-nodeWebpack build is throwing “.sourceMap is an alias for .sourceMaps, cannot use both”TS+React+Less: MiniCssExtractPlugin build ErrorReact module build failed with babel and webpack4
How important is knowledge of trig identities for use in Calculus
Does the US Armed Forces refuse to recruit anyone with an IQ less than 83?
How to say "respectively" in German when listing (enumerating) things
Can Familiars read and use spell scrolls?
Garage door sticks on a bolt
How dangerous are my worn rims?
SOQL injection vulnerability issue
Do actions granted by the Haste spell count as "your action"?
Would a horse be sufficient buffer to prevent injury when falling from a great height?
Did Tolkien ever write about a Heaven or Hell for Men?
How to identify whether a publisher is genuine or not?
How is this situation not a checkmate?
Looking for circuit board material that can be dissolved
Principled construction of the quaternions
Replace zeros in a list with last nonzero value
Can I bring this power bank on board the aircraft?
What is the meaning of first flight and introduction in aircraft production?
Knights and Knaves: What does C say?
Airport Security - advanced check, 4th amendment breach
Why does `FindFit` fail so badly in this simple case?
What action is recommended if your accommodation refuses to let you leave without paying additional fees?
麦酒 (ばくしゅ) for "beer"
Disable all sound permanently
How dangerous is a very out-of-true disc brake wheel?
babel-plugin-module-resolver (^3.2.0) does not work inside node_modules in babel 7
Babel module build failed when passing multiple presets into create-react app package.jsonwebpack context and resolve.modules not resolving node_modulesBabel-loader 8 complains about not finding deprecated babel-preset-es2015Webpack cannot identify my JSX syntax inside my js fileModule build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module 'babel-preset-react'How to transpile node_modules modules with babel-loader?How to include a few node_modules package in babel-nodeWebpack build is throwing “.sourceMap is an alias for .sourceMaps, cannot use both”TS+React+Less: MiniCssExtractPlugin build ErrorReact module build failed with babel and webpack4
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
I am also using babel 7 and webpack 4 in my project. (I am using react-native-web and native-base-web; to run my react code on the web)
I am facing an issue where the aliases in module resolver are not applied to inside the node_modules directory. (same is true with other plugins, they are not applied in node_modules directory)
In webpack, I have explicitly specified these modules to be included with the babel-loader. (see code below)
I am currently using a workaround - where I have installed these modules outside of node_modules directory. (when they are installed outside of the root node_modules folder, my babel config works on them.)
It would be good to know what could be wrong. Below are more details (snippets of babel.config.js and webpack.config.js).
Code Snippets
Below is the list and versions of babel and webpack plugins I am using.
"@babel/core": "^7.4.0",
"@babel/plugin-proposal-class-properties": "^7.4.0",
"@babel/plugin-proposal-decorators": "^7.4.0",
"@babel/polyfill": "^7.4.0",
"@babel/preset-flow": "^7.0.0",
"@babel/runtime": "^7.4.2",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^24.5.0",
"babel-loader": "^8.0.5",
"babel-plugin-module-resolver": "^3.2.0",
"babel-plugin-react-native-web": "^0.11.2",
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
"metro-react-native-babel-preset": "^0.53.1",
...
"webpack": "^4.29.6",
"webpack-cli": "^3.3.0",
"webpack-dev-server": "^3.2.1",
My babel config is placed in babel.config.js in the root folder. It is picked up when I run webpack.
module.exports = function(api)
api.cache(true);
const presets = [
"module:metro-react-native-babel-preset"
];
const plugins = [
"transform-inline-environment-variables",
[
"module-resolver",
"root": ["."],
"extensions": [".web.js", ".js", ".json"],
"alias":
"src": "./src",
"platform": "./src/platforms/messenger",
"react-navigation$": "@react-navigation/web",
"native-base-shoutem-theme": "./src/platforms/messenger/theme/native-base-shoutem-theme",
"@storybook/react-native": "@storybook/react",
"react-native": "react-native-web",
"native-base": "native-base-web",
"react/lib/ReactNativePropRegistry": "react-native-web/dist/modules/ReactNativePropRegistry",
],
["react-native-web", "commonjs": true ],
["@babel/plugin-proposal-decorators", "legacy": true ],
["@babel/plugin-proposal-class-properties", "loose": true ],
];
return
presets,
plugins,
And my webpack config is as below. (file: web/.storybook/webpack.config.js)
'use strict';
Object.defineProperty(exports, '__esModule',
value: true
);
var _path = require('path');
var _path2 = _interopRequireDefault(_path);
var _webpack = require('webpack');
var _webpack2 = _interopRequireDefault(_webpack);
function _interopRequireDefault(obj) return obj && obj.__esModule ? obj : default: obj ;
var managerEntry = process.env.DEV_BUILD ? _path2.default.resolve(__dirname, '../../src/client/manager') : _path2.default.resolve(__dirname, '../manager');
var config =
devtool: '#cheap-module-eval-source-map',
entry:
manager: [managerEntry],
preview: [_path2.default.resolve(__dirname, './error_enhancements'), 'webpack-hot-middleware/client']
,
output:
path: _path2.default.join(__dirname, 'dist'),
filename: '[name].bundle.js',
publicPath: '/static/'
,
plugins: [
new _webpack2.default.HotModuleReplacementPlugin(),
],
module:
rules: [
jsx,
png,
test: /.scss$/,
use: [
"style-loader", // creates style nodes from JS strings
"css-loader", // translates CSS into CommonJS
"sass-loader" // compiles Sass to CSS, using Node Sass by default
]
]
,
resolve:
extensions: ['.web.js', '.web.jsx', '.js', '.jsx', '.json'],
"alias":
"react-native": "react-native-web",
"native-base": "native-base-web",
"react-native/Libraries/Renderer/ReactNativePropRegistry": "react-native-web/dist/modules/ReactNativePropRegistry",
"react/lib/ReactNativePropRegistry": "react-native-web/dist/modules/ReactNativePropRegistry",
;
module.exports = config;
babel webpack-4 babel-loader
add a comment
|
I am also using babel 7 and webpack 4 in my project. (I am using react-native-web and native-base-web; to run my react code on the web)
I am facing an issue where the aliases in module resolver are not applied to inside the node_modules directory. (same is true with other plugins, they are not applied in node_modules directory)
In webpack, I have explicitly specified these modules to be included with the babel-loader. (see code below)
I am currently using a workaround - where I have installed these modules outside of node_modules directory. (when they are installed outside of the root node_modules folder, my babel config works on them.)
It would be good to know what could be wrong. Below are more details (snippets of babel.config.js and webpack.config.js).
Code Snippets
Below is the list and versions of babel and webpack plugins I am using.
"@babel/core": "^7.4.0",
"@babel/plugin-proposal-class-properties": "^7.4.0",
"@babel/plugin-proposal-decorators": "^7.4.0",
"@babel/polyfill": "^7.4.0",
"@babel/preset-flow": "^7.0.0",
"@babel/runtime": "^7.4.2",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^24.5.0",
"babel-loader": "^8.0.5",
"babel-plugin-module-resolver": "^3.2.0",
"babel-plugin-react-native-web": "^0.11.2",
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
"metro-react-native-babel-preset": "^0.53.1",
...
"webpack": "^4.29.6",
"webpack-cli": "^3.3.0",
"webpack-dev-server": "^3.2.1",
My babel config is placed in babel.config.js in the root folder. It is picked up when I run webpack.
module.exports = function(api)
api.cache(true);
const presets = [
"module:metro-react-native-babel-preset"
];
const plugins = [
"transform-inline-environment-variables",
[
"module-resolver",
"root": ["."],
"extensions": [".web.js", ".js", ".json"],
"alias":
"src": "./src",
"platform": "./src/platforms/messenger",
"react-navigation$": "@react-navigation/web",
"native-base-shoutem-theme": "./src/platforms/messenger/theme/native-base-shoutem-theme",
"@storybook/react-native": "@storybook/react",
"react-native": "react-native-web",
"native-base": "native-base-web",
"react/lib/ReactNativePropRegistry": "react-native-web/dist/modules/ReactNativePropRegistry",
],
["react-native-web", "commonjs": true ],
["@babel/plugin-proposal-decorators", "legacy": true ],
["@babel/plugin-proposal-class-properties", "loose": true ],
];
return
presets,
plugins,
And my webpack config is as below. (file: web/.storybook/webpack.config.js)
'use strict';
Object.defineProperty(exports, '__esModule',
value: true
);
var _path = require('path');
var _path2 = _interopRequireDefault(_path);
var _webpack = require('webpack');
var _webpack2 = _interopRequireDefault(_webpack);
function _interopRequireDefault(obj) return obj && obj.__esModule ? obj : default: obj ;
var managerEntry = process.env.DEV_BUILD ? _path2.default.resolve(__dirname, '../../src/client/manager') : _path2.default.resolve(__dirname, '../manager');
var config =
devtool: '#cheap-module-eval-source-map',
entry:
manager: [managerEntry],
preview: [_path2.default.resolve(__dirname, './error_enhancements'), 'webpack-hot-middleware/client']
,
output:
path: _path2.default.join(__dirname, 'dist'),
filename: '[name].bundle.js',
publicPath: '/static/'
,
plugins: [
new _webpack2.default.HotModuleReplacementPlugin(),
],
module:
rules: [
jsx,
png,
test: /.scss$/,
use: [
"style-loader", // creates style nodes from JS strings
"css-loader", // translates CSS into CommonJS
"sass-loader" // compiles Sass to CSS, using Node Sass by default
]
]
,
resolve:
extensions: ['.web.js', '.web.jsx', '.js', '.jsx', '.json'],
"alias":
"react-native": "react-native-web",
"native-base": "native-base-web",
"react-native/Libraries/Renderer/ReactNativePropRegistry": "react-native-web/dist/modules/ReactNativePropRegistry",
"react/lib/ReactNativePropRegistry": "react-native-web/dist/modules/ReactNativePropRegistry",
;
module.exports = config;
babel webpack-4 babel-loader
add a comment
|
I am also using babel 7 and webpack 4 in my project. (I am using react-native-web and native-base-web; to run my react code on the web)
I am facing an issue where the aliases in module resolver are not applied to inside the node_modules directory. (same is true with other plugins, they are not applied in node_modules directory)
In webpack, I have explicitly specified these modules to be included with the babel-loader. (see code below)
I am currently using a workaround - where I have installed these modules outside of node_modules directory. (when they are installed outside of the root node_modules folder, my babel config works on them.)
It would be good to know what could be wrong. Below are more details (snippets of babel.config.js and webpack.config.js).
Code Snippets
Below is the list and versions of babel and webpack plugins I am using.
"@babel/core": "^7.4.0",
"@babel/plugin-proposal-class-properties": "^7.4.0",
"@babel/plugin-proposal-decorators": "^7.4.0",
"@babel/polyfill": "^7.4.0",
"@babel/preset-flow": "^7.0.0",
"@babel/runtime": "^7.4.2",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^24.5.0",
"babel-loader": "^8.0.5",
"babel-plugin-module-resolver": "^3.2.0",
"babel-plugin-react-native-web": "^0.11.2",
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
"metro-react-native-babel-preset": "^0.53.1",
...
"webpack": "^4.29.6",
"webpack-cli": "^3.3.0",
"webpack-dev-server": "^3.2.1",
My babel config is placed in babel.config.js in the root folder. It is picked up when I run webpack.
module.exports = function(api)
api.cache(true);
const presets = [
"module:metro-react-native-babel-preset"
];
const plugins = [
"transform-inline-environment-variables",
[
"module-resolver",
"root": ["."],
"extensions": [".web.js", ".js", ".json"],
"alias":
"src": "./src",
"platform": "./src/platforms/messenger",
"react-navigation$": "@react-navigation/web",
"native-base-shoutem-theme": "./src/platforms/messenger/theme/native-base-shoutem-theme",
"@storybook/react-native": "@storybook/react",
"react-native": "react-native-web",
"native-base": "native-base-web",
"react/lib/ReactNativePropRegistry": "react-native-web/dist/modules/ReactNativePropRegistry",
],
["react-native-web", "commonjs": true ],
["@babel/plugin-proposal-decorators", "legacy": true ],
["@babel/plugin-proposal-class-properties", "loose": true ],
];
return
presets,
plugins,
And my webpack config is as below. (file: web/.storybook/webpack.config.js)
'use strict';
Object.defineProperty(exports, '__esModule',
value: true
);
var _path = require('path');
var _path2 = _interopRequireDefault(_path);
var _webpack = require('webpack');
var _webpack2 = _interopRequireDefault(_webpack);
function _interopRequireDefault(obj) return obj && obj.__esModule ? obj : default: obj ;
var managerEntry = process.env.DEV_BUILD ? _path2.default.resolve(__dirname, '../../src/client/manager') : _path2.default.resolve(__dirname, '../manager');
var config =
devtool: '#cheap-module-eval-source-map',
entry:
manager: [managerEntry],
preview: [_path2.default.resolve(__dirname, './error_enhancements'), 'webpack-hot-middleware/client']
,
output:
path: _path2.default.join(__dirname, 'dist'),
filename: '[name].bundle.js',
publicPath: '/static/'
,
plugins: [
new _webpack2.default.HotModuleReplacementPlugin(),
],
module:
rules: [
jsx,
png,
test: /.scss$/,
use: [
"style-loader", // creates style nodes from JS strings
"css-loader", // translates CSS into CommonJS
"sass-loader" // compiles Sass to CSS, using Node Sass by default
]
]
,
resolve:
extensions: ['.web.js', '.web.jsx', '.js', '.jsx', '.json'],
"alias":
"react-native": "react-native-web",
"native-base": "native-base-web",
"react-native/Libraries/Renderer/ReactNativePropRegistry": "react-native-web/dist/modules/ReactNativePropRegistry",
"react/lib/ReactNativePropRegistry": "react-native-web/dist/modules/ReactNativePropRegistry",
;
module.exports = config;
babel webpack-4 babel-loader
I am also using babel 7 and webpack 4 in my project. (I am using react-native-web and native-base-web; to run my react code on the web)
I am facing an issue where the aliases in module resolver are not applied to inside the node_modules directory. (same is true with other plugins, they are not applied in node_modules directory)
In webpack, I have explicitly specified these modules to be included with the babel-loader. (see code below)
I am currently using a workaround - where I have installed these modules outside of node_modules directory. (when they are installed outside of the root node_modules folder, my babel config works on them.)
It would be good to know what could be wrong. Below are more details (snippets of babel.config.js and webpack.config.js).
Code Snippets
Below is the list and versions of babel and webpack plugins I am using.
"@babel/core": "^7.4.0",
"@babel/plugin-proposal-class-properties": "^7.4.0",
"@babel/plugin-proposal-decorators": "^7.4.0",
"@babel/polyfill": "^7.4.0",
"@babel/preset-flow": "^7.0.0",
"@babel/runtime": "^7.4.2",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^24.5.0",
"babel-loader": "^8.0.5",
"babel-plugin-module-resolver": "^3.2.0",
"babel-plugin-react-native-web": "^0.11.2",
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
"metro-react-native-babel-preset": "^0.53.1",
...
"webpack": "^4.29.6",
"webpack-cli": "^3.3.0",
"webpack-dev-server": "^3.2.1",
My babel config is placed in babel.config.js in the root folder. It is picked up when I run webpack.
module.exports = function(api)
api.cache(true);
const presets = [
"module:metro-react-native-babel-preset"
];
const plugins = [
"transform-inline-environment-variables",
[
"module-resolver",
"root": ["."],
"extensions": [".web.js", ".js", ".json"],
"alias":
"src": "./src",
"platform": "./src/platforms/messenger",
"react-navigation$": "@react-navigation/web",
"native-base-shoutem-theme": "./src/platforms/messenger/theme/native-base-shoutem-theme",
"@storybook/react-native": "@storybook/react",
"react-native": "react-native-web",
"native-base": "native-base-web",
"react/lib/ReactNativePropRegistry": "react-native-web/dist/modules/ReactNativePropRegistry",
],
["react-native-web", "commonjs": true ],
["@babel/plugin-proposal-decorators", "legacy": true ],
["@babel/plugin-proposal-class-properties", "loose": true ],
];
return
presets,
plugins,
And my webpack config is as below. (file: web/.storybook/webpack.config.js)
'use strict';
Object.defineProperty(exports, '__esModule',
value: true
);
var _path = require('path');
var _path2 = _interopRequireDefault(_path);
var _webpack = require('webpack');
var _webpack2 = _interopRequireDefault(_webpack);
function _interopRequireDefault(obj) return obj && obj.__esModule ? obj : default: obj ;
var managerEntry = process.env.DEV_BUILD ? _path2.default.resolve(__dirname, '../../src/client/manager') : _path2.default.resolve(__dirname, '../manager');
var config =
devtool: '#cheap-module-eval-source-map',
entry:
manager: [managerEntry],
preview: [_path2.default.resolve(__dirname, './error_enhancements'), 'webpack-hot-middleware/client']
,
output:
path: _path2.default.join(__dirname, 'dist'),
filename: '[name].bundle.js',
publicPath: '/static/'
,
plugins: [
new _webpack2.default.HotModuleReplacementPlugin(),
],
module:
rules: [
jsx,
png,
test: /.scss$/,
use: [
"style-loader", // creates style nodes from JS strings
"css-loader", // translates CSS into CommonJS
"sass-loader" // compiles Sass to CSS, using Node Sass by default
]
]
,
resolve:
extensions: ['.web.js', '.web.jsx', '.js', '.jsx', '.json'],
"alias":
"react-native": "react-native-web",
"native-base": "native-base-web",
"react-native/Libraries/Renderer/ReactNativePropRegistry": "react-native-web/dist/modules/ReactNativePropRegistry",
"react/lib/ReactNativePropRegistry": "react-native-web/dist/modules/ReactNativePropRegistry",
;
module.exports = config;
babel webpack-4 babel-loader
babel webpack-4 babel-loader
edited Mar 28 at 21:13
flipflopapp
asked Mar 28 at 20:15
flipflopappflipflopapp
1814 silver badges16 bronze badges
1814 silver badges16 bronze badges
add a comment
|
add a comment
|
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55406163%2fbabel-plugin-module-resolver-3-2-0-does-not-work-inside-node-modules-in-babel%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55406163%2fbabel-plugin-module-resolver-3-2-0-does-not-work-inside-node-modules-in-babel%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown