Skip to content

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

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

Closed
ericfennis opened this issue Nov 8, 2018 · 0 comments

Comments

@ericfennis
Copy link

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.

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

2 participants