question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module parse failed for node_modules

See original GitHub issue

I am upgrading babel to babel 7 from babel 6. Facing below issue with one of my node_modules parse.

Package.json

"babel": {
    "presets": [
      [
        "@babel/preset-env",
        {
          "modules": false
        }
      ],
      "@babel/preset-react"
    ],
    "plugins": [
      "styled-components",
      "@babel/plugin-proposal-class-properties",
      "@babel/plugin-syntax-dynamic-import",
      "@babel/plugin-proposal-export-default-from"
    ],
    "env": {
      "production": {
        "only": [
          "app"
        ],
        "plugins": [
          "lodash",
          "transform-react-remove-prop-types",
          "@babel/plugin-transform-react-inline-elements",
          "@babel/plugin-transform-react-constant-elements",
          "@babel/plugin-transform-react-jsx"
        ]
      },
      "test": {
        "plugins": [
          "@babel/plugin-transform-modules-commonjs",
          "dynamic-import-node"
        ]
      }
    }
  },
"resolutions": {
    "babel-core": "7.0.0-bridge.0"
  },
"dependencies": {
    "@babel/polyfill": "^7.8.7"
},
"devDependencies": {
    "@babel/cli": "^7.8.4",
    "@babel/polyfill": "^7.8.7",
    "@babel/core": "^7.9.6",
    "@babel/plugin-proposal-class-properties": "^7.8.3",
    "@babel/plugin-proposal-export-default-from": "^7.8.3",
    "@babel/plugin-syntax-dynamic-import": "^7.8.3",
    "@babel/plugin-transform-modules-commonjs": "^7.9.6",
    "@babel/plugin-transform-react-constant-elements": "^7.9.0",
    "@babel/plugin-transform-react-inline-elements": "^7.9.0",
    "@babel/plugin-transform-react-jsx": "^7.9.4",
    "@babel/preset-env": "^7.9.6",
    "@babel/preset-react": "^7.9.4",
    "@babel/register": "^7.9.0",
    "babel-core": "^7.0.0-bridge.0",
    "babel-eslint": "^10.1.0",
    "babel-loader": "^8.1.0",
    "babel-plugin-dynamic-import-node": "^2.3.3",
    "babel-plugin-lodash": "^3.3.4",
    "babel-plugin-react-intl": "^7.5.7",
    "babel-plugin-react-transform": "^3.0.0",
    "babel-plugin-styled-components": "^1.10.7",
    "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
    "webpack": "^4.43.0",
    "webpack-cli": "^3.3.11",
    "webpack-dev-middleware": "^3.7.2",
    "webpack-hot-middleware": "^2.25.0",
    "webpack-pwa-manifest": "^4.2.0"
}

webpack config:

module: {
        rules: [{
            test: /\.js$/, // Transform all .js files required somewhere with Babel
            exclude: /node_modules/,
            use: {
                loader: 'babel-loader',
                options: {
                    cacheDirectory: true,
                },
            },
        }]
}

image

Need help to solve these issues with node_modules parse.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
JLHwungcommented, Jun 23, 2020

The error is thrown because your app is importing redux-form/src/createReduxForm. The src is untranspiled library source and thus never intended to be imported.

Please change your imports accordingly.

--- import createReduxForm from "redux-form/src/createReduxForm"
+++ import createReduxForm from "redux-form/lib/createReduxForm"
1reaction
nicolo-ribaudocommented, May 10, 2020

You can fix it using babel.config.json (which is applied to all the app) instead of putting the Babel configuration in package.json (which behaves as .babelrc.json and is only applied to your own files in that package).

https://babeljs.io/docs/en/config-files

Read more comments on GitHub >

github_iconTop Results From Across the Web

Private NPM library raise error "Module parse failed"
But when I want to use it in an other project, I got this error : ERROR in ./node_modules/mylib/src/views/calendar. jsx Module parse failed: ......
Read more >
Module parse failed: Unexpected character '' (1:0 ... - GitHub
Hi all. I try to load node-pty in a fresh electron application. Since there is a webpack behind the build i get the...
Read more >
[Help] Module parse failed: Unexpected token . Babel not ...
I got no errors with stable_6433, but we're building features branching from stable. My babel.config.js stays the same with 6433 and not using...
Read more >
Module parse failed: Unexpected token (1:7) - Support
Hello, there is an issue when I try to deploy my repository. For environmental variables I have CI = true. I'm using yarn...
Read more >
Webpack build error - Questions - Babylon.js Forum
Failed to compile. ./node_modules/@babylonjs/core/Misc/environmentTextureTools.js 100:39 Module parse failed: Unexpected token (100:39) File was ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found