[Solved] Error: Cannot find module './defineProperty'

This is an issue that started occurring after attempting to get a working test setup using Jest. The test itself is running just fine. Which doesn’t mean much, the app itself won’t load anymore. This is the stack-trace:

/home/csmr/Code/LUNAR/.meteor/local/build/programs/server/boot.js:475
}).run();
   ^

Error: Cannot find module './defineProperty'
    at makeMissingError (packages/modules-runtime.js:231:12)
    at require (packages/modules-runtime.js:241:19)
    at objectSpread.js (packages/modules.js:3216:22)
    at fileEvaluate (packages/modules-runtime.js:343:9)
    at require (packages/modules-runtime.js:238:16)
    at livedata_connection.js (/home/csmr/Code/LUNAR/.meteor/local/build/programs/server/packages/ddp-client.js:149:45)
    at fileEvaluate (packages/modules-runtime.js:343:9)
    at require (packages/modules-runtime.js:238:16)
    at namespace.js (packages/ddp-client/common/namespace.js:1:300)
    at fileEvaluate (packages/modules-runtime.js:343:9)
Exited with code: 1
Your application is crashing. Waiting for file change.

My package.json looks as follows:

{
    "name": "LUNAR",
    "private": true,
    "scripts": {
        "start": "meteor run",
        "test": "jest"
    },
    "dependencies": {
        "apollo-boost": "^0.1.4",
        "apollo-cache-inmemory": "^1.1.12",
        "apollo-client": "^2.2.8",
        "apollo-client-preset": "^1.0.8",
        "apollo-link-http": "^1.5.3",
        "apollo-link-state": "^0.4.1",
        "apollo-server-express": "^1.3.4",
        "applicationinsights": "^1.0.2",
        "azure": "^2.2.1-preview",
        "body-parser": "^1.18.2",
        "create-react-class": "^15.6.3",
        "d3": "^5.0.0",
        "d3-sankey": "^0.7.1",
        "d3-scale": "^2.0.0",
        "d3-selection": "^1.3.0",
        "d3-svg-legend": "^2.25.6",
        "express": "^4.16.3",
        "font-awesome": "^4.7.0",
        "google-maps-react": "^2.0.0",
        "graphql": "^0.13.2",
        "graphql-tag": "^2.8.0",
        "graphql-tools": "^2.24.0",
        "hubspot": "^1.2.5",
        "meteor-node-stubs": "^0.3.3",
        "moment": "^2.22.0",
        "node-fetch": "^2.1.2",
        "pigeon-maps": "^0.9.2",
        "pigeon-marker": "^0.3.3",
        "polished": "^1.9.2",
        "react": "^16.3.1",
        "react-addons-pure-render-mixin": "^15.6.2",
        "react-apollo": "^2.1.3",
        "react-dom": "^16.3.1",
        "react-fontawesome": "^1.6.1",
        "react-html-id": "^0.1.2",
        "react-meteor-data": "^0.2.11",
        "react-redux": "^5.0.7",
        "react-router-dom": "^4.2.2",
        "react-simple-maps": "^0.12.0",
        "redux": "^3.7.2",
        "redux-thunk": "^2.2.0",
        "request": "^2.85.0",
        "styled-components": "^3.2.5",
        "stylus": "^0.54.5",
        "topojson-client": "^3.0.0",
        "vso-node-api": "^6.5.0",
        "world-atlas": "^1.1.4"
    },
    "devDependencies": {
        "@babel/core": "^7.0.0-beta.46",
        "@babel/plugin-proposal-class-properties": "^7.0.0-beta.46",
        "@babel/polyfill": "^7.0.0-beta.46",
        "@babel/preset-env": "^7.0.0-beta.46",
        "@babel/preset-es2015": "^7.0.0-beta.46",
        "@babel/preset-react": "^7.0.0-beta.46",
        "@babel/runtime": "^7.0.0-beta.46",
        "babel-core": "^7.0.0-bridge.0",
        "babel-jest": "^22.4.3",
        "enzyme": "^3.3.0",
        "eslint": "^4.19.1",
        "eslint-config-airbnb": "^16.1.0",
        "eslint-config-prettier": "^2.9.0",
        "eslint-plugin-import": "^2.10.0",
        "eslint-plugin-jsx-a11y": "^6.0.3",
        "eslint-plugin-prettier": "^2.6.0",
        "eslint-plugin-react": "^7.7.0",
        "eslint-plugin-sort-imports-es6-autofix": "^0.3.0",
        "i": "^0.3.6",
        "jest": "^22.4.3",
        "prettier": "^1.11.1",
        "react-test-renderer": "^16.3.2",
        "react-testing-library": "^2.3.0"
    }
}

The bare minimum .babelrc that still runs the test without “issues”:

{
    "presets": ["@babel/es2015", "@babel/env", "@babel/react"],
    "plugins": ["@babel/plugin-proposal-class-properties"]
}

This is an app running on:

Node: v8.4.0
NPM: 5.4.0
Meteor: 1.6.1.1

I don’t know where to go from here. Googling on the missing ‘./defineProperty’ showed no matching results. If I were to revert back to the last working app, without testing abilities, the package.json would look like this:

{
  "name": "LUNAR",
  "private": true,
  "scripts": {
    "start": "meteor run"
  },
  "dependencies": {
    "@babel/runtime": "^7.0.0-beta.44",
    "apollo-boost": "^0.1.4",
    "apollo-cache-inmemory": "^1.1.12",
    "apollo-client": "^2.2.8",
    "apollo-client-preset": "^1.0.8",
    "apollo-link-http": "^1.5.3",
    "apollo-link-state": "^0.4.1",
    "apollo-server-express": "^1.3.4",
    "applicationinsights": "^1.0.2",
    "azure": "^2.2.1-preview",
    "babel-runtime": "^6.20.0",
    "body-parser": "^1.18.2",
    "create-react-class": "^15.6.3",
    "d3": "^5.0.0",
    "d3-sankey": "^0.7.1",
    "d3-scale": "^2.0.0",
    "d3-selection": "^1.3.0",
    "d3-svg-legend": "^2.25.6",
    "express": "^4.16.3",
    "font-awesome": "^4.7.0",
    "google-maps-react": "^2.0.0",
    "graphql": "^0.13.2",
    "graphql-tag": "^2.8.0",
    "graphql-tools": "^2.24.0",
    "hubspot": "^1.2.5",
    "meteor-node-stubs": "^0.3.3",
    "moment": "^2.22.0",
    "node-fetch": "^2.1.2",
    "pigeon-maps": "^0.9.2",
    "pigeon-marker": "^0.3.3",
    "polished": "^1.9.2",
    "react": "^16.3.1",
    "react-addons-pure-render-mixin": "^15.6.2",
    "react-apollo": "^2.1.3",
    "react-dom": "^16.3.1",
    "react-fontawesome": "^1.6.1",
    "react-html-id": "^0.1.2",
    "react-meteor-data": "^0.2.11",
    "react-redux": "^5.0.7",
    "react-router-dom": "^4.2.2",
    "react-simple-maps": "^0.12.0",
    "redux": "^3.7.2",
    "redux-thunk": "^2.2.0",
    "request": "^2.85.0",
    "styled-components": "^3.2.5",
    "stylus": "^0.54.5",
    "topojson-client": "^3.0.0",
    "vso-node-api": "^6.5.0",
    "world-atlas": "^1.1.4"
  },
  "devDependencies": {
    "eslint": "^4.19.1",
    "eslint-config-airbnb": "^16.1.0",
    "eslint-config-prettier": "^2.9.0",
    "eslint-plugin-import": "^2.10.0",
    "eslint-plugin-jsx-a11y": "^6.0.3",
    "eslint-plugin-prettier": "^2.6.0",
    "eslint-plugin-react": "^7.7.0",
    "eslint-plugin-sort-imports-es6-autofix": "^0.3.0",
    "i": "^0.3.6",
    "prettier": "^1.11.1"
  }
}

A few dependencies have changed to solve other issues whilst trying to setup testing.

EDIT: Making .babelrc look like this, however:

{
    "presets": [
        "@babel/preset-es2015",
        "@babel/preset-env",
        "@babel/preset-react"
    ],
    "plugins": ["@babel/plugin-proposal-class-properties"]
}

Gives back the following stack-trace:



Errors prevented startup:

While processing files with ecmascript (for target web.browser):
/home/csmr/Code/LUNAR/node_modules/@babel/plugin-transform-classes/lib/transformClass.js:662:25: path.isInStrictMode is not a function
  at classTransformer (/home/csmr/Code/LUNAR/node_modules/@babel/plugin-transform-classes/lib/transformClass.js:662:25)
  at transformClass (/home/csmr/Code/LUNAR/node_modules/@babel/plugin-transform-classes/lib/transformClass.js:704:10)
  at PluginPass.ClassExpression (/home/csmr/Code/LUNAR/node_modules/@babel/plugin-transform-classes/lib/index.js:106:54)
  at newFn (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/visitors.js:243:21)
  at NodePath._call (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/path/context.js:65:18)
  at NodePath.call (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/path/context.js:40:17)
  at NodePath.visit (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/path/context.js:100:12)
  at TraversalContext.visitQueue (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/context.js:144:16)
  at TraversalContext.visitSingle (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/context.js:104:19)
  at TraversalContext.visit (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/context.js:185:19)
  at Function.traverse.node (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/index.js:106:17)
  at NodePath.visit (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/path/context.js:107:18)
  at TraversalContext.visitQueue (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/context.js:144:16)
  at TraversalContext.visitMultiple (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/context.js:99:17)
  at TraversalContext.visit (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/context.js:183:19)
  at Function.traverse.node (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/index.js:106:17)
  at NodePath.visit (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/path/context.js:107:18)
  at TraversalContext.visitQueue (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/context.js:144:16)
  at TraversalContext.visitQueue (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/context.js:150:21)
  at TraversalContext.visitMultiple (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/context.js:99:17)
  at TraversalContext.visit (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/context.js:183:19)
  at Function.traverse.node (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/index.js:106:17)
  at NodePath.visit (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/path/context.js:107:18)
  at TraversalContext.visitQueue (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/context.js:144:16)
  at TraversalContext.visitSingle (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/context.js:104:19)
  at TraversalContext.visit (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/context.js:185:19)
  at Function.traverse.node (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/index.js:106:17)
  at traverse (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/traverse/lib/index.js:76:12)
  at transformFile (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/core/lib/transformation/index.js:116:29)
  at runSync (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/core/lib/transformation/index.js:45:3)
  at transformFromAstSync (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/core/lib/transform-ast-sync.js:18:38)
  at Object.transformFromAst (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/@babel/core/lib/transform-ast.js:22:68)
  at transform (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/meteor-babel/index.js:71:30)
  at compile (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/meteor-babel/index.js:91:14)
  at Cache.Cp.get (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/meteor-babel/cache.js:101:26)
  at Object.compile (/home/csmr/.meteor/packages/ecmascript/.0.10.7.pkcp4e.ralwb++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/meteor-babel/index.js:46:23)
  at Object.compile (packages/babel-compiler.js:51:29)
  at packages/babel-compiler.js:184:22
  at Function.time (/tools/tool-env/profile.js:305:10)
  at profile (packages/babel-compiler.js:232:20)
  at BabelCompiler.BCp.processOneFileForTarget (packages/babel-compiler.js:183:20)
  at BabelCompiler.<anonymous> (packages/babel-compiler.js:111:26)
  at Array.forEach (<anonymous>)
  at BabelCompiler.BCp.processFilesForTarget (packages/babel-compiler.js:110:14)

Which, to me, makes it sound like it’s either an issue with Meteor or Babel and I don’t know which one it is.

EDIT 2: Never mind, I’m an idiot. Decided to look at it from a different angle and moved some devDeps to regular deps:

{
    "name": "LUNAR",
    "private": true,
    "scripts": {
        "start": "meteor run",
        "test": "jest"
    },
    "dependencies": {
        "apollo-boost": "^0.1.4",
        "apollo-cache-inmemory": "^1.1.12",
        "apollo-client": "^2.2.8",
        "apollo-client-preset": "^1.0.8",
        "apollo-link-http": "^1.5.3",
        "apollo-link-state": "^0.4.1",
        "apollo-server-express": "^1.3.4",
        "applicationinsights": "^1.0.2",
        "azure": "^2.2.1-preview",
        "@babel/core": "^7.0.0-beta.46",
        "@babel/plugin-proposal-class-properties": "^7.0.0-beta.46",
        "@babel/polyfill": "^7.0.0-beta.46",
        "@babel/preset-env": "^7.0.0-beta.46",
        "@babel/preset-es2015": "^7.0.0-beta.46",
        "@babel/preset-react": "^7.0.0-beta.46",
        "@babel/runtime": "^7.0.0-beta.46",
        "body-parser": "^1.18.2",
        "create-react-class": "^15.6.3",
        "d3": "^5.0.0",
        "d3-sankey": "^0.7.1",
        "d3-scale": "^2.0.0",
        "d3-selection": "^1.3.0",
        "d3-svg-legend": "^2.25.6",
        "express": "^4.16.3",
        "font-awesome": "^4.7.0",
        "google-maps-react": "^2.0.0",
        "graphql": "^0.13.2",
        "graphql-tag": "^2.8.0",
        "graphql-tools": "^2.24.0",
        "hubspot": "^1.2.5",
        "meteor-node-stubs": "^0.3.3",
        "moment": "^2.22.0",
        "node-fetch": "^2.1.2",
        "pigeon-maps": "^0.9.2",
        "pigeon-marker": "^0.3.3",
        "polished": "^1.9.2",
        "react": "^16.3.1",
        "react-addons-pure-render-mixin": "^15.6.2",
        "react-apollo": "^2.1.3",
        "react-dom": "^16.3.1",
        "react-fontawesome": "^1.6.1",
        "react-html-id": "^0.1.2",
        "react-meteor-data": "^0.2.11",
        "react-redux": "^5.0.7",
        "react-router-dom": "^4.2.2",
        "react-simple-maps": "^0.12.0",
        "redux": "^3.7.2",
        "redux-thunk": "^2.2.0",
        "request": "^2.85.0",
        "styled-components": "^3.2.5",
        "stylus": "^0.54.5",
        "topojson-client": "^3.0.0",
        "vso-node-api": "^6.5.0",
        "world-atlas": "^1.1.4"
    },
    "devDependencies": {
        "babel-core": "^7.0.0-bridge.0",
        "babel-jest": "^22.4.3",
        "enzyme": "^3.3.0",
        "eslint": "^4.19.1",
        "eslint-config-airbnb": "^16.1.0",
        "eslint-config-prettier": "^2.9.0",
        "eslint-plugin-import": "^2.10.0",
        "eslint-plugin-jsx-a11y": "^6.0.3",
        "eslint-plugin-prettier": "^2.6.0",
        "eslint-plugin-react": "^7.7.0",
        "eslint-plugin-sort-imports-es6-autofix": "^0.3.0",
        "i": "^0.3.6",
        "jest": "^22.4.3",
        "prettier": "^1.11.1",
        "react-test-renderer": "^16.3.2",
        "react-testing-library": "^2.3.0"
    }
}

It’s working again, both the app and the test files. Sigh…

1 Like

Nice. I solved this yesterday coincidentally :joy: Its your babel package. It should be in your dependencies, not in your devDependencies.

"dependencies": {
        "@babel/core": "^7.0.0-beta.46",
        "meteor-node-stubs": "^0.3.2",

Instead of:

"devDependencies": {
        "@babel/core": "^7.0.0-beta.46",
        "meteor-node-stubs": "^0.3.2",