2

Transpiling javascript code using babel-cli via grunt. Seeing error "path.inShadow is not a function" when transpiling first javascript file containing a class definition.

I believe that I have fully updated node and all of the packages (I'm new to the node ecosystem, so perhaps I'm missing something here).

Here's the snippet showing my dev dependencies.

"devDependencies": {
    "@babel/core": "^7.2.2",
    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.3",
    "babel-preset-env": "^1.7.0",
    "grunt": "^1.0.3",
    "grunt-babel": "^8.0.0",
    "grunt-contrib-clean": "^2.0.0",
    "grunt-contrib-compress": "^1.4.3",
    "grunt-contrib-concat": "^1.0.1",
    "grunt-contrib-copy": "^1.0.0",
    "grunt-contrib-jasmine": "^2.0.3",
    "grunt-contrib-jshint": "^2.0.0",
    "grunt-contrib-rename": "^0.2.0",
    "grunt-contrib-uglify": "^4.0.0",
    "grunt-contrib-watch": "^1.1.0"
  }

I believe that my installis current because:

  • npm install does nothing
  • npm outdated shows nothing
  • npm prune does nothing

node version is 10.15.0.

On a Mac in case that's relevant

Transpilation aborts with the error message:

Warning: path.inShadow is not a function Use --force to continue.

It appears to be compiling a javascript file containing a class definition at the time, none of the preceding files that are successfully transpiled contain such definitions.

atline
  • 28,355
  • 16
  • 77
  • 113
dbp
  • 91
  • 1
  • 12
  • Perhaps try installing [babel-plugin-transform-es2015-classes](https://www.npmjs.com/package/babel-plugin-transform-es2015-classes) and add `"plugins": ["transform-es2015-classes"]` to your `.babelrc` file. – RobC Jan 22 '19 at 13:08
  • 1
    @RobC -- thanks for responding. What you suggested didn't work, but using the more recent @babel/plugin-transform-classes has changed the error. – dbp Jan 22 '19 at 18:31
  • 1
    @RobC -- just to close the loop. Resolving unrelated error solved all my problems (well, the babel-related ones, anyway). Thanks again. – dbp Jan 22 '19 at 19:44

1 Answers1

4

Following @RobC's suggestion. Here's the answer:

  1. Install @babel/plugin-transform-classes

  2. and add"plugins": [ "@babel/plugin-transform-classes" ] to .babelrc.

Problem solved.

RobC
  • 22,977
  • 20
  • 73
  • 80
dbp
  • 91
  • 1
  • 12