Wanted to get started wi…

2 minute read

Wanted to get started with a new project this morning, entered npx create-nx-workspace@latest new-project into the terminal and was greeted with this error: npx: installed 199 in 7.791s Must use import to load ES Module: /Users/leifwells/.npm/_npx/65026/lib/node_modules/create-nx-workspace/node_modules/is-promise/index.js require() of ES modules is not supported. require() of /Users/leifwells/.npm/_npx/65026/lib/node_modules/create-nx-workspace/node_modules/is-promise/index.js from /Users/leifwells/.npm/_npx/65026/lib/node_modules/create-nx-workspace/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 /Users/leifwells/.npm/_npx/65026/lib/node_modules/create-nx-workspace/node_modules/is-promise/index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/leifwells/.npm/_npx/65026/lib/node_modules/create-nx-workspace/node_modules/is-promise/package.json. I think this is an npx error, but… I have no idea. I searched the issues on the github repo and searched here without finding anything. Anyone have any thoughts?

Responses:

Hmm i’ve got same issue what version of node

Invalid "exports" main target "index.js" defined in the package config /home/libertyware/.npm/_npx/25360/lib/node_modules/create-nx-workspace/node_modules/is-promise/package.json

issue is this https://github.com/then/is-promise/issues/12

Package just broken react and angular too :sweat_smile:

I have node v12.16.1

Yea should be fixed shortly they just broke eveything

Awesome. :cry:

Half the internet now broken

Just half?

will that package is used ALOT 11,697,391 downloads a week. thats react, angular and i believe vue and alot of node frameworks

Somebody must have deployed on a Friday!

Nope did it 31 minutes ago

``` module.exports = isPromise; module.exports.default = isPromise;

function isPromise(obj) { return !!obj && (typeof obj === ‘object’ || typeof obj === ‘function’) && typeof obj.then === ‘function’; }``` thats the NPM code in the package like why are people using this

So, what you’re saying is that if I had gotten out of bed 30 minutes earlier I may have avoided this? :wink:

Yes

but… I needed my beauty sleep!

one minute

What u can do is clone the repo and add a resolution in the package json

then use npm link so it uses the locally installed version

"resolutions": { "is-promise": "2.1.0", "run-async/is-promise": "2.1.0", "memoizee/is-promise": "2.1.0" } add that to you package json

That… sounds like a headache for a Saturday. I’m going to go watch some videos on http://egghead.io|egghead.io instead. Thanks for your suggestion. I think I can wait until this gets fixed officially.

This was a funny read

seems like Javascript community hasn’t learnt it’s lesson from left-pad

They most definitely have not. That is true

I’ve never heard of this package. I would never use an npm package for such a small issue. It add risk to your code

function isPromise(obj) { return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; } There must be a better way to tell if something is a promise… right?

is they is

function isPromise(obj) { return typeof obj?.then === 'function'; } or what i do function alwaysPromise (obj) { return Promise.resolve(obj); }

just make the everything a promise. rather than checking and reacting to it

ya the only standard for promises is an object with a then function.

but ya doing Promise.resolve will convert it to a trusted primise,

the issue is native promises in js and then bluebird promises. It means you cant just use instance of

Yea so whats wrong with making it a promise

Shouldn’t be anything wrong with it :man-shrugging: But the JS community looooves their small packages

Yep. no lesson learnt. It;s going to make a nice blog to laugh at

> the JS community looooves their small packages

Fixed: https://github.com/then/is-promise/releases

Updated: