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

export 'default' (imported as '__vue_script__') was not found in #997

Closed
qinshenxue opened this issue Sep 30, 2017 · 5 comments

Comments

@qinshenxue
Copy link

@qinshenxue qinshenxue commented Sep 30, 2017

.babelrc

 "presets": [
        ["env", { "modules": false }]
 ]

when i use import in vue files, it occurs the following warnings. and it's ok with require.

<script>
import 'style.less'
</script>
"export 'default' (imported as '__vue_script__') was not found in '!!babel-loader!../../../node_modules/vue-loader/lib/selector?type=script&index=0!./less.vue'

package.json

{
        "babel-core": "^6.26.0",
        "babel-loader": "^7.1.2",
        "babel-preset-env": "^1.6.0",
        "vue": "^2.4.4",
        "vue-loader": "^13.0.5",
        "vue-router": "^2.7.0",
        "vue-template-compiler": "^2.4.4",
        "webpack": "^3.6.0",
        "webpack-dev-server": "^2.9.1",
}

is there any problems ?

@LinusBorg

This comment has been minimized.

Copy link
Member

@LinusBorg LinusBorg commented Oct 2, 2017

Pleaser use forum.vuejs.org or chat.vuejs.org for questions.

@LinusBorg LinusBorg closed this Oct 2, 2017
@qinshenxue

This comment has been minimized.

Copy link
Author

@qinshenxue qinshenxue commented Nov 29, 2017

I finally found the solution and the reason. Setting modules with false means that babel don't resolve module system any more.
So far, webpack don't support dynamic import, so we should add a dynamic-import plugin by ourselves.

npm install --save-dev babel-plugin-syntax-dynamic-import

.babelrc

{
    "presets": [
        [
            "env",
            {
                "modules": false
            }
        ]
    ],
    "plugins": [
        "syntax-dynamic-import"
    ]
}
@Jinjiang

This comment has been minimized.

Copy link
Member

@Jinjiang Jinjiang commented Nov 29, 2017

We couldn't see the whole project you mentioned. But I guess this error means you don't export anything in <script>.

If you add a line of code: export default {}, maybe it won't be error again.

If a Vue sfc doesn't have any <script> part that's OK. But if it has, you must export something (even just a empty plain object).

Thanks.

@qinshenxue

This comment has been minimized.

Copy link
Author

@qinshenxue qinshenxue commented Nov 29, 2017

@Jinjiang thanks
the really reason!

@PradeepThite

This comment has been minimized.

Copy link

@PradeepThite PradeepThite commented Sep 11, 2018

@Jinjiang thanks
the really reason!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.