简体   繁体   English

babel.config.js:加载配置时出错 - 找不到模块“纤维”

[英]babel.config.js: Error while loading config - Cannot find module 'fibers'

This is driving me nuts.这让我发疯了。

IDE: Visual Studion 2019 Project: Created a new "Basic Vue.js project" - I chose the *.ts flavour IDE:Visual Studion 2019 项目:创建了一个新的“基本 Vue.js 项目”——我选择了 *.ts 风格

I validate the new site runs.我验证了新站点的运行。 It does.确实如此。

Following the quick start on Vuetify: https://vuetifyjs.com/en/getting-started/quick-start/#bootstrapping-the-vuetify-object在 Vuetify 快速入门之后: https://vuetifyjs.com/en/getting-started/quick-start/#bootstrapping-the-vuetify-object

After each step I validate the site will still compile and run.在每一步之后,我都会验证该站点仍将编译和运行。

I reach the section where we add new modules to our project.我到达了我们向项目添加新模块的部分。 I run this line:我运行这条线:

npm install sass sass-loader fibers deepmerge -D

And now the site will not run.现在该网站将无法运行。 When I debug I get this output:当我调试时,我得到这个 output:

------ Build started: Project: MCCC.Web, Configuration: Debug Any CPU ------
        > mccc.web@0.1.0 build C:\Labs\MCCC\Web\MCCC-Web\MCCC.Web
        > vue-cli-service build
        -  Building for production...
        Starting type checking service...
        Using 1 worker with 2048MB memory limit
         ERROR  Failed to compile with 1 errors5:04:50 PM
         error  in ./src/main.ts
        Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
        Thread Loader (Worker 0)
        C:\Labs\MCCC\Web\MCCC-Web\MCCC.Web\babel.config.js: Error while loading config - Cannot find module 'fibers'
            at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
            at Function.Module._load (internal/modules/cjs/loader.js:562:25)
            at Module.require (internal/modules/cjs/loader.js:690:17)
            at require (internal/modules/cjs/helpers.js:25:18)
            at Object.<anonymous> (C:\Labs\MCCC\Web\MCCC-Web\MCCC.Web\babel.config.js:17:32)
            at Module._compile (internal/modules/cjs/loader.js:776:30)
            at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
            at Module.load (internal/modules/cjs/loader.js:653:32)
            at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
            at Function.Module._load (internal/modules/cjs/loader.js:585:3)
         @ multi ./src/main.ts
         ERROR  Build failed with errors.
        npm ERR! code ELIFECYCLE
        npm ERR! errno 1
        npm ERR! mccc.web@0.1.0 build: `vue-cli-service build`
        npm ERR! Exit status 1
        npm ERR! 
        npm ERR! Failed at the mccc.web@0.1.0 build script.
        npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
        npm ERR! A complete log of this run can be found in:
        npm ERR!     C:\Users\Dwainwright.BC\AppData\Roaming\npm-cache\_logs\2020-04-26T21_04_50_521Z-debug.log
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VisualStudio\v16.0\Node.js Tools\Microsoft.NodejsToolsV2.targets(60,5): error MSB3073: The command "npm run build" exited with code 1.
Done building project "MCCC.Web.njsproj" -- FAILED.

Build FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The line that sticks out the most to me is:最让我印象深刻的一句话是:

C:\Labs\MCCC\Web\MCCC-Web\MCCC.Web\babel.config.js: Error while loading config - Cannot find module 'fibers'

fibres is references in the babel.config.json where I added the rules laid out in quick start:纤维是 babel.config.json 中的引用,我在其中添加了快速入门中列出的规则:

module.exports = {
  presets: [
        '@vue/app',
        '@babel/preset-env'
    ],
    rules: [
        {
            test: /\.s(c|a)ss$/,
            use: [
                'vue-style-loader',
                'css-loader',
                {
                    loader: 'sass-loader',
                    // Requires sass-loader@^7.0.0
                    options: {
                    implementation: require('sass'),
                    fiber: require('fibers'),
                    indentedSyntax: true // optional
                },
                // Requires sass-loader@^8.0.0
                options: {
                    implementation: require('sass'),
                    sassOptions: {
                        fiber: require('fibers'),
                        indentedSyntax: true // optional
                    },
                },
            },
        ],
    },
]
};

Does anybody know how i can resolve this?有谁知道我该如何解决这个问题? Happy to share further info;很高兴分享更多信息; not sure what else you may need.不确定您可能还需要什么。

Are you using the latest version of the docs?您使用的是最新版本的文档吗? I followed the link you provided and the anchor #bootstrapping-the-vuetify-object doesn't appear to exist anymore.我按照您提供的链接进行操作,并且锚#bootstrapping-the-vuetify-object似乎不再存在。 I was able to get a basic project up and running successfully following these steps:按照以下步骤,我能够成功启动并运行一个基本项目:

  1. vue create myapp : Selected "custom" and ticked all the boxes, for TypeScript, chose the default "class-style components" vue create myapp :选择“自定义”并勾选所有框,对于 TypeScript,选择默认的“类样式组件”
  2. verified that npm run serve worked验证npm run serve有效
  3. vue add vuetify : Selected "Configure", and these options: vue add vuetify :选择“配置”,这些选项:
    1. Y (default) Y(默认)
    2. y是的
    3. y是的
    4. Material Design Icons (default)材料设计图标(默认)
    5. N (default) N(默认)
    6. Y (default) Y(默认)
    7. English (default)英语(默认)
  4. npm run serve would run, but I got warnings about type declaration for vuetify/lib . npm run serve会运行,但我收到有关vuetify/lib类型声明的警告。 This answer led me to this FAQ item which made the warnings go away. 这个答案让我看到了这个常见问题解答项目,它使警告 go 消失了。 (You have to add "vuetify" to the compilerOptions.types array in the root tsconfig.json for the project.) (您必须将"vuetify"添加到项目根tsconfig.json中的compilerOptions.types数组中。)

FWIW, fibers does not appear to be included in the project at all anymore (searched for "fibers" in package-lock.json ). FWIW, fibers似乎不再包含在项目中(在package-lock.json中搜索“纤维”)。 My babel.config.js file looks like:我的babel.config.js文件看起来像:

module.exports = {
  presets: [
    '@vue/cli-plugin-babel/preset'
  ]
}

And vue.config.js looks like: vue.config.js看起来像:

module.exports = {
  transpileDependencies: [
    'vuetify'
  ]
}

Hope this helps!希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM