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

ERR_INVALID_PACKAGE_TARGET #13

Closed
Sorunome opened this issue Apr 25, 2020 · 24 comments
Closed

ERR_INVALID_PACKAGE_TARGET #13

Sorunome opened this issue Apr 25, 2020 · 24 comments

Comments

@Sorunome
Copy link

@Sorunome Sorunome commented Apr 25, 2020

The module fails to import with node v13.12.0. The version 2.1.0 still works fine.

sorunome@sorunome-desktop repos/mx-puppet-skype $ node ./build/index.js                                 1
internal/modules/cjs/loader.js:616
            if (e.code !== 'ERR_PACKAGE_PATH_NOT_EXPORTED') throw e;
                                                            ^

Error [ERR_INVALID_PACKAGE_TARGET]: Invalid "exports" main target "index.js" defined in the package config /home/sorunome/repos/mx-puppet-skype/node_modules/is-promise/package.json
    at resolveExportsTarget (internal/modules/cjs/loader.js:574:13)
    at resolveExportsTarget (internal/modules/cjs/loader.js:613:20)
    at applyExports (internal/modules/cjs/loader.js:503:14)
    at resolveExports (internal/modules/cjs/loader.js:541:12)
    at Function.Module._findPath (internal/modules/cjs/loader.js:661:22)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:963:27)
    at Function.Module._load (internal/modules/cjs/loader.js:859:27)
    at Module.require (internal/modules/cjs/loader.js:1036:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/home/sorunome/repos/mx-puppet-skype/node_modules/lowdb/lib/main.js:4:17) {
  code: 'ERR_INVALID_PACKAGE_TARGET'
}
cipchk added a commit to ng-alain/delon that referenced this issue Apr 25, 2020
- tracking then/is-promise#13
@DeabitTech
Copy link

@DeabitTech DeabitTech commented Apr 25, 2020

so this is resolved?

@knrz
Copy link

@knrz knrz commented Apr 25, 2020

Nope, and it's broken serverless for me :(

@cipchk
Copy link

@cipchk cipchk commented Apr 25, 2020

Similar:

Unknown error: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/vsts/work/1/s/node_modules/is-promise/index.js
require() of ES modules is not supported.
require() of /home/vsts/work/1/s/node_modules/is-promise/index.js from /home/vsts/work/1/s/node_modules/run-async/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename /home/vsts/work/1/s/node_modules/is-promise/index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/vsts/work/1/s/node_modules/is-promise/package.json.

A full log refer to azure pipelines

@Sorunome
Copy link
Author

@Sorunome Sorunome commented Apr 25, 2020

so this is resolved?

Nope, it got broken in the 2.2.0 update about an hour ago and there is no fix for it yet

@monken
Copy link

@monken monken commented Apr 25, 2020

The left pad fiasco all over. https://www.theregister.co.uk/2016/03/23/npm_left_pad_chaos/

It's a single line of code. Why do we need a package for this?

@onhate
Copy link

@onhate onhate commented Apr 25, 2020

Same is happening to me, started some minutes ago:

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: .../node_modules/is-promise/index.js
require() of ES modules is not supported.
@samblake
Copy link

@samblake samblake commented Apr 25, 2020

Broke Serverless for me too! :(

@RyanZim
Copy link
Contributor

@RyanZim RyanZim commented Apr 25, 2020

Duplicate of #12.

@knrz
Copy link

@knrz knrz commented Apr 25, 2020

If you're using Yarn here's a fix:

  1. Run yarn why is-promise
  2. For every package that depends on is-promise, pin the resolution. In my case, serverless was installing run-async and memoizee, which each had their own copy of is-promise. I added the following key to my package.json:
  "resolutions": {
    "is-promise": "2.1.0",
    "run-async/is-promise": "2.1.0",
    "memoizee/is-promise": "2.1.0"
  }

Then I rm -rf'd the directories with run-async and memoizee and reinstalled them using yarn add. Works for me 👍

@mistakenot
Copy link

@mistakenot mistakenot commented Apr 25, 2020

Broke create-react-app for me.

$ npx create-react-app my-app
npx: installed 99 in 7.558s
Must use import to load ES Module: /home/charlie/.npm/_npx/20884/lib/node_modules/create-react-app/node_modules/is-promise/index.js
require() of ES modules is not supported.
@crsohr
Copy link

@crsohr crsohr commented Apr 25, 2020

If you're using npm, you can fix the issue by editing your package-lock.json file like so.

Identify the modules that are using the failing is-promise modules:

 "run-async": {                                                                                                                                                                                                                
      "version": "2.4.0",                                                                                                                                                                                                         
      "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.0.tgz",                                                                                                                                                   
      "integrity": "sha512-xJTbh/d7Lm7SBhc1tNvTpeCHaEzoyxPrqNlvSdMfBTYwaY++UJFyXUOxAtsRUXjlqOfj8luNaR9vjCh4KeV+pg==",                                                                                                             
      "dev": true,                                                                                                                                                                                                                
      "requires": {                                                                                                                                                                                                               
        "is-promise": "^2.1.0"                                                                                                                                                                                                    
      }                                                                                                                                                                                                                           
    },

Move the is-promise out of requires and create a new object dependencies:

"run-async": {                                                                                                                                                                                                                
      "version": "2.4.0",                                                                                                                                                                                                         
      "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.0.tgz",                                                                                                                                                   
      "integrity": "sha512-xJTbh/d7Lm7SBhc1tNvTpeCHaEzoyxPrqNlvSdMfBTYwaY++UJFyXUOxAtsRUXjlqOfj8luNaR9vjCh4KeV+pg==",                                                                                                             
      "dev": true,                                                                                                                                                                                                                
      "dependencies": {                                                                                                                                                                                                           
        "is-promise": {                                                                                                                                                                                                           
          "version": "2.1.0"                                                                                                                                                                                                      
        }                                                                                                                                                                                                                         
      }                                                                                                                                                                                                                           
},

Next, rerun npm install --only=dev and you should be good.

(If using yarn, see comment #13)

@akctba
Copy link

@akctba akctba commented Apr 25, 2020

package-lock.jso

but how to do it to create a new project using npx create-react-app?

@alexandernst
Copy link

@alexandernst alexandernst commented Apr 25, 2020

😂 holy shit 😂 JS ecosystem is just utterly broken beyond any repair.

@SimonSchick
Copy link

@SimonSchick SimonSchick commented Apr 25, 2020

Fyi, this is on hackernews, expect a lot attention/comments/shitposting.

@jcao219
Copy link

@jcao219 jcao219 commented Apr 25, 2020

https://deno.land/ piling on the bandwagon

@aeolingamenfel
Copy link

@aeolingamenfel aeolingamenfel commented Apr 25, 2020

This also seems to be affecting latest on firebase-tools.

@crsohr
Copy link

@crsohr crsohr commented Apr 25, 2020

This also seems to be affecting latest on firebase-tools.

This is affecting so many packages, this is also affecting npx eslint --init 😥

@MarkKragerup
Copy link

@MarkKragerup MarkKragerup commented Apr 25, 2020

If you are on NPM, run:
npm install is-promise@2.1.0 --save --save-exact

@preetjdp
Copy link

@preetjdp preetjdp commented Apr 25, 2020

If you are on NPM, run:
npm install is-promise@2.1.0 --save --save-exact

Does this work if a 3rd party dependency uses is-promise ?

@jschuur
Copy link

@jschuur jschuur commented Apr 25, 2020

Does this work if a 3rd party dependency uses is-promise ?

It just did for me. inquirer needed run-async which needed is-promise.

@MarkKragerup
Copy link

@MarkKragerup MarkKragerup commented Apr 25, 2020

If you are on NPM, run:
npm install is-promise@2.1.0 --save --save-exact

Does this work if a 3rd party dependency uses is-promise ?

I'm unsure exactly what dependencies i have that were broken - but it was for sure more than one. It's some big projects, worked on all of them.

@FdezRomero
Copy link

@FdezRomero FdezRomero commented Apr 25, 2020

@tyvdh
Copy link

@tyvdh tyvdh commented Apr 25, 2020

If you are on NPM, run:
npm install is-promise@2.1.0 --save --save-exact

Didn't work for me :(

@ForbesLindesay
Copy link
Member

@ForbesLindesay ForbesLindesay commented Apr 25, 2020

It should now be resolved. Since there are 4 issues about this, I'm going to close this issue in favour of #20. Please comment there if 2.2.1 does not fix your issue.

@then then locked and limited conversation to collaborators Apr 25, 2020
cryptoquick added a commit to cryptoquick/demo-cra-ts that referenced this issue Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.