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 use vue cli commands in v4.3.1 #5422

Closed
amansharma007 opened this issue Apr 25, 2020 · 9 comments
Closed

Cannot use vue cli commands in v4.3.1 #5422

amansharma007 opened this issue Apr 25, 2020 · 9 comments

Comments

@amansharma007
Copy link

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..

@raj1rana
Copy link

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

@kolaval
Copy link

kolaval commented Apr 25, 2020

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?

@amansharma007
Copy link
Author

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

@amansharma007
Copy link
Author

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..

@LinusBorg
Copy link
Member

LinusBorg commented Apr 25, 2020

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)

@LinusBorg
Copy link
Member

LinusBorg commented Apr 25, 2020

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

then/is-promise#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 LinusBorg pinned this issue Apr 25, 2020
@amansharma007
Copy link
Author

@LinusBorg
Thanks for stating the actual issue 👍
Was starting to doubt Vue CLI v4.3.1 😅

@amansharma007
Copy link
Author

@LinusBorg
Copy link
Member

Should finally be resolved in their v2.2.2

@haoqunjiang haoqunjiang unpinned this issue Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants