Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module '@babel/runtime/core-js/object/define-property' #140

Closed
lipsumar opened this issue Aug 6, 2018 · 23 comments
Closed

Cannot find module '@babel/runtime/core-js/object/define-property' #140

lipsumar opened this issue Aug 6, 2018 · 23 comments

Comments

@lipsumar
Copy link

lipsumar commented Aug 6, 2018

Just updated to 3.7.0 and as soon as i import gitlab/dist/es5, I get:

Error: Cannot find module '@babel/runtime/core-js/object/define-property'
    at Function.Module._resolveFilename (module.js:527:15)
    at Function.Module._load (module.js:476:23)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/John/my-project/on-demand-bulk-killer/node_modules/gitlab/dist/es5/index.js:7:30)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/John/my-project/on-demand-bulk-killer/lib/index.js:2:16)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)

I'm using node v8.7.0

@lipsumar
Copy link
Author

lipsumar commented Aug 6, 2018

to be precise I require it:

const Gitlab = require('gitlab/dist/es5').default
const gitlab = new Gitlab({
    url: 'https://git.my-company.com',
    token: 'xxx'
});

@jag-tus
Copy link

jag-tus commented Aug 6, 2018

I had the same issue. I will end up upgrading to node v8 and using the ES6 version, and therefore bypass the issue, but here is a hint to help you along the way if you need to stick with ES5.

I noticed the following lines in dist/es5/index.js:

var _Object$defineProperty = require("@babel/runtime/core-js/object/define-property");

var _Object$keys = require("@babel/runtime/core-js/object/keys");

If you look for these files in node_modules/@babel/runtime/, you will find that core-js/ doesn't exist. There are two fixes I can imagine:

  1. Figure out the appropriate version of babel-runtime (the one that has core-js).
  2. Update the es5 version of this package.
    e.g. var _Object$defineProperty = require("@babel/runtime/helpers/defineProperty");. Note that I don't know what keys has been renamed to and how many other places you'll need to make this update.

Make sure that whatever changes you make, you make a pull-request and you meet all PR requirements (passing tests, etc).

Good luck!

@jag-tus
Copy link

jag-tus commented Aug 6, 2018

If it's just a question of not being able to use the import keyword:

const Gitlab = require('gitlab').default;

@BBKolton
Copy link

BBKolton commented Aug 7, 2018

@jag-tus 's workaround works

Does anyone know why this update broke ES5 support? It was pretty frustrating having it work one day and break the next

@GreenGremlin
Copy link

My guess would be something changed in @babel/runtime, likely this change.

@GreenGremlin
Copy link

It looks like re-building and re-publishing might fix it.

@lipsumar
Copy link
Author

lipsumar commented Aug 7, 2018

Indeed, if I clone the project and rebuild it then it works. This is pretty annoying. @jdalrymple please rebuild and push updated version 🙏

In the meantime here's what i have:

create a install-gitlab.sh file:

if [ -d "./node-gitlab" ]; then
  rm -rf ./node-gitlab
fi
git clone https://github.com/jdalrymple/node-gitlab.git
cd node-gitlab
npm install
npm run build

make it executable:

chmod u+x ./install-gitlab.sh

Add this to your package.json:

"preinstall": "./install-gitlab.sh"

Then change your dependency to your local copy:

  "dependencies": {
    "gitlab": "./node-gitlab"
  }

And finally npm install

@GreenGremlin
Copy link

GreenGremlin commented Aug 7, 2018

Or just

npm install --save jdalrymple/node-gitlab

Might work

@jdalrymple
Copy link
Owner

Will do ASAP!! Sorry for all the trouble everyone :(

@jdalrymple
Copy link
Owner

jdalrymple commented Aug 7, 2018

I broke something. Still looking into it. For whatever reason, the release stage is failing due to a missing module that doesnt seem to be missing on the test or lint stages. https://travis-ci.org/jdalrymple/node-gitlab/jobs/413361700

@NBardelot
Copy link

NBardelot commented Aug 8, 2018

This issue is blocking, and seems a little harder to fix than expected. Even rolling back to older versions of the gitlab module does not work, because the @babel/runtime dependency is set to use the latest release in your package.json.

Would you please consider forcing the version of @babel/runtime to 7.0.0-beta.55 instead of ^7.0.0-beta.56 on the master? That would give you time to fix the issue on a branch, while unblocking every user hit by the issue like me. Thanks.

Edit :

For those interested, as a workaround forcing the @babel/runtime version in our own module's package.json worked.

@jdalrymple
Copy link
Owner

Yup that seems like a smarter idea. I'll make the change today

@jdalrymple
Copy link
Owner

Hmm, not really sure why this isnt working. I set all the babel related packages to 7.0.0-beta.55 instead of ^7.0.0-beta.56 but travis is still failing with a module not found error.

npm WARN prepare removing existing node_modules/ before installation
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module '../pack.js'
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/travis/.npm/_logs/2018-08-08T15_00_40_854Z-debug.log
The command "eval npm ci  " failed. Retrying, 2 of 3.
/home/travis/.travis/job_stages: line 257: ./node_modules/.bin/npm: No such file or directory
The command "eval npm ci  " failed. Retrying, 3 of 3.
/home/travis/.travis/job_stages: line 257: ./node_modules/.bin/npm: No such file or directory
The command "eval npm ci  " failed 3 times.
The command "npm ci " failed and exited with 127 during .

Any other suggestions? Sorry for the all the hassle!

@jdalrymple
Copy link
Owner

May be related to this version of npm/node. Testing with v10.0.0

@jdalrymple
Copy link
Owner

So after restricting it to v10.0.0 It passed the lint and test stages, but still fails with that error on release. 🙃

@jdalrymple
Copy link
Owner

I've also rerun the same job multiple times and have gotten different errors inconsistently ...

@jdalrymple
Copy link
Owner

Asking the travis team: travis-ci/travis-ci#9965

@jabinb
Copy link

jabinb commented Aug 9, 2018

If you're using yarn you can add a resolutions key to your package.json

  "resolutions": {
    "@babel/runtime": "7.0.0-beta.55"
  }

@jdalrymple
Copy link
Owner

Still no suggestions from the travis team. I guess il start stripping the build process to narrow down where the problem may be.

@Sechgulo
Copy link

Sechgulo commented Aug 14, 2018

Can confirm that forcing the @babel/runtime version to 7.0.0-beta.55 in our own package.json as a temporary fix solved it (we're not using Travis in any way).

@jdalrymple
Copy link
Owner

It ended up being caused by the cached npm folder

@jdalrymple
Copy link
Owner

Does the var @babel/runtime/core-js/object/define-property error persist with the rc1 release of babel?

jdalrymple pushed a commit that referenced this issue Aug 14, 2018
# [3.8.0](3.7.0...3.8.0) (2018-08-14)

### Bug Fixes

* **api:** Updating project members all function to include the inherited members.  [#141](#141) ([e081a16](e081a16))
* **package:** update [@semantic-release](https://github.com/semantic-release)/npm to version 5.0.0 ([dc9748d](dc9748d))
* **package:** update [@semantic-release](https://github.com/semantic-release)/npm to version 5.0.1 ([12b6ca1](12b6ca1)), closes [#139](#139)
* **package:** Updating packages and fixing [#140](#140) due to a babel update ([04d1769](04d1769))

### Features

* Add push rule service ([#143](#143)) ([395f83c](395f83c))
* Add transfer a project to a new namespace ([#145](#145)) ([87e9f55](87e9f55))
@jdalrymple
Copy link
Owner

Reopen if its still an issue!! :D

mdsb100 pushed a commit to mdsb100/node-gitlab that referenced this issue Aug 17, 2018
# [3.8.0](jdalrymple/gitbeaker@3.7.0...3.8.0) (2018-08-14)

### Bug Fixes

* **api:** Updating project members all function to include the inherited members.  [jdalrymple#141](jdalrymple#141) ([e081a16](jdalrymple@e081a16))
* **package:** update [@semantic-release](https://github.com/semantic-release)/npm to version 5.0.0 ([dc9748d](jdalrymple@dc9748d))
* **package:** update [@semantic-release](https://github.com/semantic-release)/npm to version 5.0.1 ([12b6ca1](jdalrymple@12b6ca1)), closes [jdalrymple#139](jdalrymple#139)
* **package:** Updating packages and fixing [jdalrymple#140](jdalrymple#140) due to a babel update ([04d1769](jdalrymple@04d1769))

### Features

* Add push rule service ([jdalrymple#143](jdalrymple#143)) ([395f83c](jdalrymple@395f83c))
* Add transfer a project to a new namespace ([jdalrymple#145](jdalrymple#145)) ([87e9f55](jdalrymple@87e9f55))
mdsb100 pushed a commit to mdsb100/node-gitlab that referenced this issue Aug 17, 2018
# [3.8.0](jdalrymple/gitbeaker@3.7.0...3.8.0) (2018-08-14)

### Bug Fixes

* **api:** Updating project members all function to include the inherited members.  [jdalrymple#141](jdalrymple#141) ([e081a16](jdalrymple@e081a16))
* **package:** update [@semantic-release](https://github.com/semantic-release)/npm to version 5.0.0 ([dc9748d](jdalrymple@dc9748d))
* **package:** update [@semantic-release](https://github.com/semantic-release)/npm to version 5.0.1 ([12b6ca1](jdalrymple@12b6ca1)), closes [jdalrymple#139](jdalrymple#139)
* **package:** Updating packages and fixing [jdalrymple#140](jdalrymple#140) due to a babel update ([04d1769](jdalrymple@04d1769))

### Features

* Add push rule service ([jdalrymple#143](jdalrymple#143)) ([395f83c](jdalrymple@395f83c))
* Add transfer a project to a new namespace ([jdalrymple#145](jdalrymple#145)) ([87e9f55](jdalrymple@87e9f55))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants