Skip to content

GeneratorAPI injectImports() function won't inject imports in an empty file. #2925

Closed
@ericfennis

Description

@ericfennis

Version

3.1.1

Reproduction link

https://github.com/ericfennis/vue-cli-iniectImport-bug

Node and OS info

node 8.12.0 / yarn 1.10.1 / MAC OSX Mojave

Steps to reproduce

  1. Clone Repo

  2. yarn to install dependecies

  3. vue invoke bug

  4. watch in cli:
    ERROR TypeError: Cannot convert undefined or null to object
    TypeError: Cannot convert undefined or null to object...

  5. See location of the code in generator.js on line 15 in ./vue-cli-plugin-inject-bug/generator.js

What is expected?

Run vue invoke and the function inject the import in the empty file.

What is actually happening?

Gives error Object is null/undefined.

ERROR TypeError: Cannot convert undefined or null to object
TypeError: Cannot convert undefined or null to object
at injectImportsAndOptions (/Users/ericfennis/.config/yarn/global/node_modules/@vue/cli/lib/util/injectImportsAndOptions.js:28:28)
at Object.keys.forEach.file (/Users/ericfennis/.config/yarn/global/node_modules/@vue/cli/lib/Generator.js:211:21)
at Array.forEach ()
at Generator.resolveFiles (/Users/ericfennis/.config/yarn/global/node_modules/@vue/cli/lib/Generator.js:210:24)
at Generator.generate (/Users/ericfennis/.config/yarn/global/node_modules/@vue/cli/lib/Generator.js:116:16)
at runGenerator (/Users/ericfennis/.config/yarn/global/node_modules/@vue/cli/lib/invoke.js:121:19)
at
at process._tickCallback (internal/process/next_tick.js:189:7)


I try to make a generator for a project and I want to inject importers in an empty file to register to export default them.

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