Vue-cli: Cannot use vue cli commands in v4.3.1

Created on 25 Apr 2020  路  9Comments  路  Source: vuejs/vue-cli

Version

4.3.1

Reproduction link

https://github.com/amansharma007/vue-router-demo

Environment info

node version: v14.0.0
npm version: v6.14.4

Steps to reproduce

After running npm install -g @vue/cli run vue create app-name and you will get this error,

internal/modules/cjs/loader.js:584
            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/aman/.nvm/versions/node/v14.0.0/lib/node_modules/@vue/cli/node_modules/is-promise/package.json
    at resolveExportsTarget (internal/modules/cjs/loader.js:542:13)
    at resolveExportsTarget (internal/modules/cjs/loader.js:581:20)
    at applyExports (internal/modules/cjs/loader.js:455:14)
    at resolveExports (internal/modules/cjs/loader.js:508:23)
    at Function.Module._findPath (internal/modules/cjs/loader.js:632:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1001:27)
    at Function.Module._load (internal/modules/cjs/loader.js:884:27)
    at Module.require (internal/modules/cjs/loader.js:1074:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/home/aman/.nvm/versions/node/v14.0.0/lib/node_modules/@vue/cli/node_modules/run-async/index.js:3:17) {
  code: 'ERR_INVALID_PACKAGE_TARGET'
}

What is expected?

The expected result is that vue cli creates a vue project.

What is actually happening?

Any vue cli commands are showing the same error above..

bug upstream

All 9 comments

same issue here
ERROR Error [ERR_INVALID_PACKAGE_TARGET]: Invalid "exports" main target "index.js" defined in the package config /usr/local/share/.config/yarn/global/node_modules/is-promise/package.json
Error [ERR_INVALID_PACKAGE_TARGET]: Invalid "exports" main target "index.js" defined in the package config /usr/local/share/.config/yarn/global/node_modules/is-promise/package.json
at resolveExportsTarget (internal/modules/cjs/loader.js:542:13)
at resolveExportsTarget (internal/modules/cjs/loader.js:581:20)
at applyExports (internal/modules/cjs/loader.js:455:14)
at resolveExports (internal/modules/cjs/loader.js:508:23)
at Function.Module._findPath (internal/modules/cjs/loader.js:632:31)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1001:27)
at Function.Module._load (internal/modules/cjs/loader.js:884:27)
at Module.require (internal/modules/cjs/loader.js:1074:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object. (/usr/local/share/.config/yarn/global/node_modules/lowdb/lib/main.js:4:17)

Node version 14

Same issue here except I cannot even install @vue/cli.

Googling around indicates that it is a node issue as react devs are also experiencing the same?

I think this issue has come up with the new v4.3.1 release.. If someone knows the command to downgrade to an older version using npm, then do let know.
PS: vue upgrade vX.X.X is also not working, showing the same errors

Everyone, I found the solution to this,
Don't just install @vue/cli you also have to install @vue/cli-service with it. I don't know why they have not yet updated that in the vue-cli documentation

Run this command, and you are golden:

npm install -g @vue/cli @vue/cli-service

Comment here if this works for all of you guys.. It worked for me..

You should not install vue-cli-seevixe globally. It's a project dependency, installed locally for every project that's using it.

The underlying problem is a bug in a transitive dependency named is-promise, so the issue is with that package, not vue-cli directly.

That package also broke create-react-app, for example.

When using yarn, you can probably use the resolutions field to force this package to use an older, bug-free version.

Will comment with a concrete example shortly (edit: that only works for existing projects)

So it seems that is-promise 2.2.1 fixes the problem.

https://github.com/then/is-promise/issues/20

If you continue to experience this issue when running vur create, reinstall @vue/cli.

If it still happens for you when running vue-cli-service, delete the lockfile and reinstall your dependencies (or adjust the lockfile version manually)

@LinusBorg
Thanks for stating the actual issue :+1:
Was starting to doubt Vue CLI v4.3.1 :sweat_smile:

Should finally be resolved in their v2.2.2

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CodeApePro picture CodeApePro  路  3Comments

eladcandroid picture eladcandroid  路  3Comments

miyamoto-san picture miyamoto-san  路  3Comments

OmgImAlexis picture OmgImAlexis  路  3Comments

BusyHe picture BusyHe  路  3Comments