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
Closed

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

qinshenxue opened this issue Sep 30, 2017 · 5 comments

Comments

@qinshenxue
Copy link

.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
Copy link
Member

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

@qinshenxue
Copy link
Author

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
Copy link
Member

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
Copy link
Author

@Jinjiang thanks
the really reason!

@PradeepThite
Copy link

@Jinjiang thanks
the really reason!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants