Skip to content

Received "TypeError: Path must be a string. Received undefined" when using "vue add" #3804

Closed
@ivanreyne

Description

@ivanreyne

Version

3.6.1

Environment info

Environment Info:

  System:
    OS: Linux 4.15 Ubuntu 18.04.2 LTS (Bionic Beaver)
    CPU: (8) x64 Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz
  Binaries:
    Node: 8.10.0 - /usr/bin/node
    Yarn: Not Found
    npm: 3.5.2 - /usr/bin/npm
  Browsers:
    Chrome: 73.0.3683.103
    Firefox: 66.0.2
  npmGlobalPackages:
    @vue/cli: 3.6.1

Steps to reproduce

Create a new vue project:

vue create testapp1
cd vue testapp1
vue add vuetify

FAILS

What is expected?

📦 Installing vue-cli-plugin-vuetify...

✔ Successfully installed plugin: vue-cli-plugin-vuetify

? Choose a preset: Default (recommended)

🚀 Invoking generator for vue-cli-plugin-vuetify...
⚓ Running completion hooks...

✔ Successfully invoked generator for plugin: vue-cli-plugin-vuetify
The following files have been updated / added:

 src/assets/logo.svg
 src/plugins/vuetify.js
 package.json
 public/index.html
 src/App.vue
 src/components/HelloWorld.vue
 src/main.js
 src/views/Home.vue

You should review these changes with git diff and commit them.

What is actually happening?

📦 Installing vue-cli-plugin-vuetify...

ERROR TypeError: Path must be a string. Received undefined
TypeError: Path must be a string. Received undefined
at assertPath (path.js:28:11)
at Object.join (path.js:1236:7)
at exports.hasProjectPnpm (/usr/local/lib/node_modules/@vue/cli/node_modules/@vue/cli-shared-utils/lib/env.js:113:25)
at add (/usr/local/lib/node_modules/@vue/cli/lib/add.js:30:94)
at module.exports.args (/usr/local/lib/node_modules/@vue/cli/lib/add.js:66:10)
at Command.program.command.description.option.allowUnknownOption.action (/usr/local/lib/node_modules/@vue/cli/bin/vue.js:86:26)
at Command.listener (/usr/local/lib/node_modules/@vue/cli/node_modules/commander/index.js:315:8)
at emitTwo (events.js:126:13)
at Command.emit (events.js:214:7)
at Command.parseArgs (/usr/local/lib/node_modules/@vue/cli/node_modules/commander/index.js:651:12)


I did a bit of debug and the problem is caused because no "cwd" argument is passed to the calls of the function "hasProjectPnpm" from @vue/cli-shared-utils/lib/env.js:113

In this simple "add" case there are two places where this happen:

at add (/usr/local/lib/node_modules/@vue/cli/lib/add.js:30:94)

and later at:

at runGenerator (/usr/local/lib/node_modules/@vue/cli/lib/invoke.js:148:75)

You will see something similar to this (from invoke.js):

loadOptions().packageManager || (hasProjectYarn(context) ? 'yarn' : hasProjectPnpm() ? 'pnpm' : 'npm')

where the "hasProjectPnpm" function is called without arguments but it needs the cwd (context) as the other "hasProjectYarn" function, it should be like this:

loadOptions().packageManager || (hasProjectYarn(context) ? 'yarn' : hasProjectPnpm(context) ? 'pnpm' : 'npm')

I report it here because rather than submitting a patch because I am not familiar with the vue-cli code and it might affect other commands and other places as well.

Regards,

Ivan.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions