Skip to content

[Bug] Yarn Nightly and "type": "module" fail to work #985

@dzintars

Description

@dzintars
  • I'd be willing to implement a fix

Describe the bug

In order to enable "type": "module" is seen some reports that i should upgrade to latest Berry version. yarn set version berry seems does not work because i was getting (node:1563141) ExperimentalWarning: The ESM module loader is experimental. +"<long minified output> error all the time.

To Reproduce
Create empty directory and check version:

mkdir yarn && cd yarn
yarn --version
1.23.0-20200205.1242

As told in documentation, Yarn 1 is accessible globally.

Check other parties:

node --version
v13.9.0
npm --version
6.13.7

Seems latest or at least one of the latest versions.

Now let's enable nightly:

yarn init -y
yarn set version nightly
yarn --version
1.23.0-20200205.1242

As we see i get no any effect. Still Yarn 1.
BTW - .yarnrc#yarn-path seems to be fixed now and have relative path yarn-path ".yarn/releases/yarn-nightly.js" :)

Let's clean up and enable Berry:

rm -rf .yarn/ && rm .yarnrc.yml
yarn set version berry
yarn --version
2.0.0-rc.29

This time it works like expected (i hope).

Now let's add "type": "module" in package.json and check yarn version again. In theory because i have Node 13 it should work.:
And we get an error again:

(node:1588502) ExperimentalWarning: The ESM module loader is experimental.                               file:///home/dzintars/Code/yarn/.yarn/releases/yarn-berry.js:2

<long-minified-output-of module.exports=function(e){var t={};..../>

ReferenceError: module is not defined
    at file:///home/dzintars/Code/yarn/.yarn/releases/yarn-berry.js:2:1
    at ModuleJob.run (internal/modules/esm/module_job.js:110:37)
    at async Loader.import (internal/modules/esm/loader.js:167:24)

I would be very grateful for any hints of mistakes i made.

Environment if relevant (please complete the following information):

  • OS: [Linux]
  • Node version [v13.9.0]
  • Yarn version [1.23.0-20200205.1242 or 2.0.0-rc.29]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions