当前位置: 首页 > 知识库问答 >
问题:

Nuxtjs:模块解析失败:意外字符“@”

谢嘉
2023-03-14

我从Windows转到MacOS,下载了其中一个项目,但我有一个无法修复的错误。我的其他同事也有macOS,但我是唯一一个有M1的人。

2021-09-08 23:20:07[记录][友好错误]2021-09-08 23:20:07[错误][友好错误]输入/页面/程序/网络挂钩/添加/索引。vue?vue

  • /node_modules/vue loader/lib/index。js您可能需要额外的加载器来处理这些加载器的结果从“~/components/shared/NewBreadcrumb/index”导入NewBreadcrumb。vue'|@组件({124; name:'add webhook',|组件:{NewHeader,NewTabs,NewFormLabel,NewSelect,NewInput,newreadcrumb},2021-09-08 23:20:07[log][友好错误]@./pages/program/webhooks/add/index.vue?vue
/* eslint-disable prefer-template */
import _ from 'lodash';
import { logHandler, setupLogging } from './tools/logger';
import config from './config';
import healthCheck from './tools/health-check';
import s3Images from './tools/s3-images';

require('dotenv').config();
require('events').EventEmitter.defaultMaxListeners = 50;

process.env.DEBUG = process.env.DEBUG || 'axios:err,nuxt_config,feature,client';
setupLogging();

export default () => {
let env = process.env.NUXT_ENV;
const build = process.env.npm_lifecycle_event === 'build';

if (!_.includes(['development', 'integration', 'test', 'staging', 'production'], env)) {
    if (build) {
        // env has no effect on build, but needed for valid config
        env = 'production';
    } else {
        throw new Error('NUXT_ENV not set properly');
    }
}

console.log(`NUXT_ENV ${env}`); // eslint-disable-line

return {
    /*
     ** Headers of the page
     */
    head: {
        title: 'p4management',
        meta: [
            { charset: 'utf-8' },
            {
                name: 'viewport',
                content: 'width=device-width, initial-scale=1',
            },
            {
                hid: 'description',
                name: 'description',
                content: 'frontend for managing and configuring p4m services',
            },
        ],
        link: [
            {
                rel: 'icon',
                type: 'image/x-icon',
                href: config.baseUrl + 'favicon.ico',
            },
        ],
        bodyAttrs: {
            class: '--nav-fixed',
        }
    },

    env: {
        release: process.env.RELEASE,
        environment: process.env.NUXT_ENV
    },

    /*
     ** Build configuration
     */
    buildModules: ['@nuxt/typescript-build'],
    build: {
        /*
         ** Run ESLint on save
         */
        extend(cfg, { isDev, isClient }) {
            if (isDev && isClient) {
                cfg.module.rules.push({
                    enforce: 'pre',
                    test: /\.(js|vue|ts)$/,
                    loader: 'eslint-loader',
                    exclude: /(node_modules)/,
                });
            }
            // eslint-disable-next-line
            cfg.node = {
                fs: 'empty',
            };
        },
    },
    modules: [
        '@nuxtjs/axios',
        '@nuxtjs/auth',
        '@nuxtjs/toast',
        '@nuxtjs/style-resources',
        '@nuxtjs/sentry',
        '@nuxt/typescript-build',
        '@nuxtjs/device',
    ],
    axios: {
        proxy: true,
        prefix: config.baseUrl,
        https: true,
    },
    proxy: {
        // css files for Legacy Selfservice
        [config.baseUrl + 'pfm/selfservice/css/style.css']: {
            target: `http://localhost:3000${config.baseUrl}/legacy/pfm/style.css`,
            pathRewrite: { '.*': '' },
        },
        [config.baseUrl + 'ocm/selfservice/css/style.css']: {
            target: `http://localhost:3000${config.baseUrl}/legacy/ocm/style.css`,
            pathRewrite: { '.*': '' },
        },
        [config.baseUrl + 'nyo/selfservice/css/style.css']: {
            target: `http://localhost:3000${config.baseUrl}/legacy/pfm/style.css`,
            pathRewrite: { '.*': '' },
        },
        // S3 images
        // [config.baseUrl + 's3-images']: {
        //     target: `http://localhost:3000${config.baseUrl}/s3-images`,
        //     pathRewrite: { '^.*/': '/' },
        //     hostRewrite: true,
        // },
        // Legacy Selfservice
        [config.baseUrl + 'pfm/selfservice/']: {
            target: config.environment[env].legacySelfserviceUrl,
            pathRewrite: { '^.*/selfservice/': '/' },
            hostRewrite: true,
        },
        [config.baseUrl + 'ocm/selfservice/']: {
            target: config.environment[env].legacySelfserviceUrl.replace('//', '//ocm.'),
            pathRewrite: { '^.*/selfservice/': '/' },
            hostRewrite: true,
        },
        [config.baseUrl + 'nyo/selfservice/']: {
            target: config.environment[env].legacySelfserviceUrl.replace('//', '//nyo.'),
            pathRewrite: { '^.*/selfservice/': '/' },
            hostRewrite: true,
        },
        // Api's
        [config.baseUrl + 'api2/']: {
            target: config.environment[env].api2Url,
            pathRewrite: { '^.*/api2/': '/' },
        },
        [config.baseUrl + 'api/']: {
            target: config.environment[env].apiUrl,
            pathRewrite: { '^.*/api/': '/' },
        },
        [config.baseUrl + 'device-management/']: {
            target: config.environment[env].deviceApiUrl,
            pathRewrite: { '^.*/device-management/': '/' },
        },
        [config.baseUrl + 'device-managements/']: {
            target: config.environment[env].deviceApiUrl2,
            pathRewrite: { '^.*/device-managements/': '/' },
        },
        [config.baseUrl + 'bonscan-clarification/']: {
            target: config.environment[env].clarificationApiUrl,
            pathRewrite: { '^.*/bonscan-clarification/': '/' },
        },
        [config.baseUrl + 'webhooks/']: {
            target: config.environment[env].webhookApiUrl,
            pathRewrite: { '^.*/webhooks/': '/' },
        },
    },
    styleResources: {
        scss: ['~/assets/styles/globals.scss'],
    },
    auth: {
        plugins: ['./plugins/axios.js'],
        redirect: {
            login: '/login',
            logout: '/login',
            home: false,
        },
        strategies: {
            local: {
                _scheme: 'local',
                endpoints: {
                    login: {
                        url: '/api/auth-admin/login',
                        method: 'post',
                        propertyName: null,
                    },
                    logout: false,
                    user: false,
                },
                tokenRequired: true,
                tokenType: '',
            },
            local2: {
                _scheme: 'local',
                endpoints: {
                    login: {
                        url: '/api2/auth/login',
                        method: 'post',
                        propertyName: null,
                    },
                    logout: false,
                    user: false,
                },
                tokenRequired: true,
                tokenType: '',
            },
        },
    },
    toast: {
        position: 'top-right',
        duration: 2200,
        theme: 'toasted-primary',
    },
    sentry: {
        dsn: 'https://47be963b68db4fa88c9907caa4066183@o146990.ingest.sentry.io/5240221',
        disabled: process.env.NUXT_ENV === 'development',
        publishRelease: ['staging', 'production'].includes(process.env.NUXT_ENV),
        config: {
            environment: process.env.NUXT_ENV,
        },
    },
    plugins: [
        './plugins/errorNotification.js',
        './plugins/directives.js',
        './plugins/feature.js',
        './plugins/filter.js',
        './plugins/font.js',
        './plugins/i18n.js',
        './plugins/lodash.js',
        './plugins/mixins.js',
        './plugins/nuxtClientInit.js',
        './plugins/validate.js',
        './plugins/vuikit.js',
        { src: './plugins/vue-tags-input.js', ssr: false },
        { src: './plugins/shortkey.js', ssr: false },
        { src: './plugins/photo-zoom-pro.js', ssr: false },
        { src: './plugins/quill.js', ssr: false },
    ],
    css: [
        '@fortawesome/fontawesome-svg-core/styles.css',
        '@vuikit/theme/dist/vuikit.css',
        '@voerro/vue-tagsinput/dist/style.css',
        'flatpickr/dist/flatpickr.min.css',
        'vue-multiselect/dist/vue-multiselect.min.css',
    ],
    /*
     ** Router config
     */
    router: {
        base: config.baseUrl,
        middleware: ['auth', 'checkRoles'],
    },
    serverMiddleware: [
        { path: '/health', handler: healthCheck },
        { path: '/log', handler: logHandler },
        { path: '/s3-images', handler: s3Images },
    ],
};
};

指数vue:

<template src="./index.html"></template>
<style scoped lang="scss" src="./styles.scss"></style>
<script lang="ts">
import { Vue, Component } from 'vue-property-decorator';
import { ActionConfigDTO, EventData } from '../interfaces.vue';
import NewHeader from '~/components/shared/NewHeader/index.vue';
import NewTabs from '~/components/shared/NewTabs/index.vue';
import NewFormLabel from '~/components/shared/NewFormLabel/index.vue';
import NewSelect, { SelectOption } from '~/components/shared/NewSelect/index.vue';
import NewInput from '~/components/shared/NewInput/index.vue';
import NewBreadcrumb from '~/components/shared/NewBreadcrumb/index.vue';

@Component({
    name: 'add-webhook',
    components: { NewHeader, NewTabs, NewFormLabel, NewSelect, NewInput, NewBreadcrumb },
    fetch: async ({ store }) => {
        try {
            await store.dispatch('webhook/fetchEventList', {});
        } catch (err) {
            store.dispatch('error', err);
        }
    },
})
export default class AddWebhook extends Vue {
    public actionConfig: ActionConfigDTO = { domainType: '', event: '', url: '' };
    public domainTypeList: SelectOption[] = this.getDomainTypeList();
    public eventList: SelectOption[] = [];
    public newHeaders: any = { key: null, value: null };

    public onCancel(): void {
        this.$router.push(`/program/webhooks`);
    }

    public async onSave(): Promise<void> {
        try {
            await this.$store.dispatch('webhook/addActionConfig', this.actionConfig);
            this.$toast.success(this.$t('program.webhooks.added') as string);
            this.$router.push(`/program/webhooks`);
        } catch (err) {
            this.$store.dispatch('error', err);
        }
    }

    public selectDomainType(domainType: string): void {
        this.actionConfig.domainType = domainType;
        this.eventList = this.getEventList(domainType);
    }

    public selectEvent(event: string): void {
        this.actionConfig.event = event;
    }

    public selectUrl(url: string): void {
        this.actionConfig.url = url;
    }

    public changeHeader(key: string, value: string): void {
        this.actionConfig.headers = { ...this.actionConfig.headers, [key]: value };
    }

    public changeNewHeadersValue(value: string){
        this.newHeaders.value = value;
    }

    public changeNewHeadersKey(key: string){
        this.newHeaders.key = key;
    }

    public addHeader(): void {
        this.actionConfig.headers = { ...this.actionConfig.headers, [this.newHeaders.key]: this.newHeaders.value };
        this.newHeaders = { key: null, value: null };
    }

    public removeHeader(key: string): void {
        Vue.delete(this.actionConfig.headers, key)
        this.$forceUpdate()
    }

    public isSaveDisabled(): boolean {
        return !this.actionConfig.domainType || !this.actionConfig.event || !this.actionConfig.url;
    }

    private getDomainTypeList(): SelectOption[] {
        return this.$store.state.webhook.eventList
            .map((event: EventData) => event.domainType)
            .filter((event: EventData, index: number, self: EventData[]) => self.indexOf(event) === index)
            .map((domainType: string) => ({ name: domainType, value: domainType }));
    }

    private getEventList(domainType: string): SelectOption[] {
        return this.$store.state.webhook.eventList
            .filter((event: EventData) => event.domainType === domainType)
            .map((event: EventData) => ({ name: event.name, value: event.name }));
    }
}
</script>

共有1个答案

唐炳
2023-03-14

这似乎是一个输入错误/页面/程序/网络挂钩/添加/索引。vue Nuxt。我想,配置对理解这种情况并不是很有用

 类似资料:
  • 模块解析失败:意外令牌Reactjs? ./src/index.js 6:4模块解析失败时出错:意外标记(6:4)您可能需要适当的加载程序来处理此文件类型,目前没有配置加载程序来处理此文件。看见https://webpack.js.org/concepts#loaders || ReactDOM.render( |document.getElementById('app')|); @multi./

  • 大家好。有人能帮帮我吗?我只是创建react应用程序,然后我立即启动它。然后我得到了类似这样的错误。我不知道出了什么问题 编译失败。./src/index.js 1:68模块解析失败:使用以下加载程序处理了意外的令牌(1:68)文件: null

  • 更新: 代码推送到 初始投递: 我的Package.json 我的webpack.config.js 我的巴贝尔rc ./src/index.js 5:16模块解析失败中的错误:意外标记(5:16)您可能需要一个适当的加载程序来处理此文件类型。从“./components/App”导入App;reactdom.render(,document.getElementById('root'));//R

  • 更新: 代码推送到 初始职位: 我知道有数百个线程,有些在webpack配置中有错别字,有些以错误的方式使用加载器,有些解决了它,有些仍然打开。但是经过无数次尝试,我仍然无法让这个工作,一个简单的“你好世界”使用Webpack 4,反应js。 我做过的事 我是按照这个视频教程一行行:反应 我的package.json 我的webpack.config.js 我的. babelrc 我的目录结构 预

  • 继幸存的JS电子书我试图设置我的ReactJS项目webpack配置。 在运行我的开始脚本时,我得到以下错误: ./app/index.js模块解析失败时出错:/Users/shooste/PersonalProjects/surviveJS/node_modules/eslint loader/index.js/Users/shooshte/PersonalProjects/surviveJS/

  • 嗨,我是学生开发者。我面临这样的错误 ./src/index.js 5:16模块解析失败时出错:意外标记(5:16)您可能需要适当的加载程序来处理此文件类型,目前没有配置加载程序来处理此文件。看见https://webpack.js.org/concepts#loaders |从“../src/components/App”导入应用程序| ReactDOM.render(,document.get