Использование mjs в проекте Next.js - PullRequest
0 голосов
/ 12 июня 2019

Когда я использую mjs в своем проекте Next.js, я сталкиваюсь с ошибкой ниже:

Can't reexport the named export 'getLastPosition' from non EcmaScript module (only default export is available)
ModuleDependencyError: Can't reexport the named export 'getLastPosition' from non EcmaScript module (only default export is available)
    at Compilation.reportDependencyErrorsAndWarnings (D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\webpack\lib\Compilation.js:1374:21)
    at D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\webpack\lib\Compilation.js:1168:10
    at AsyncSeriesHook.eval [as callAsync] (eval at create (D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:15:1)
    at AsyncSeriesHook.lazyCompileHook (D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\tapable\lib\Hook.js:154:20)
    at Compilation.finish (D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\webpack\lib\Compilation.js:1163:28)
    at D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\webpack\lib\Compiler.js:622:17
    at _done (eval at create (D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:9:1)
    at eval (eval at create (D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:31:22)
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
ModuleDependencyError: Can't reexport the named export 'getLastPosition' from non EcmaScript module (only default export is available)
    at Compilation.reportDependencyErrorsAndWarnings (D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\webpack\lib\Compilation.js:1374:21)
    at D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\webpack\lib\Compilation.js:1168:10
    at AsyncSeriesHook.eval [as callAsync] (eval at create (D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:15:1)
    at AsyncSeriesHook.lazyCompileHook (D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\tapable\lib\Hook.js:154:20)
    at Compilation.finish (D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\webpack\lib\Compilation.js:1163:28)
    at D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\webpack\lib\Compiler.js:622:17
    at _done (eval at create (D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:9:1)
    at eval (eval at create (D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:31:22)
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
ModuleDependencyError: Can't reexport the named export 'getLastPosition' from non EcmaScript module (only default export is available)
    at Compilation.reportDependencyErrorsAndWarnings (D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\webpack\lib\Compilation.js:1374:21)
    at D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\webpack\lib\Compilation.js:1168:10
    at AsyncSeriesHook.eval [as callAsync] (eval at create (D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:15:1)
    at AsyncSeriesHook.lazyCompileHook (D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\tapable\lib\Hook.js:154:20)
    at Compilation.finish (D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\webpack\lib\Compilation.js:1163:28)
    at D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\webpack\lib\Compiler.js:622:17
    at _done (eval at create (D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:9:1)
    at eval (eval at create (D:\WorkHouse\scenario-bus\scenario-bus-fe-console\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:31:22)
    at processTicksAndRejections (internal/process/task_queues.js:89:5)

Кажется, следующий код не может быть использован Next.js.

export { getTrackSplit, getTrack, getLastPosition } from './webclient/position.mjs';

Кроме того, этот код:

export * from './webclient/position.mjs';

Итак, как использовать mjs в проекте Next.js?

1 Ответ

0 голосов
/ 13 июня 2019

Это моя вина.Я забыл перенести библиотеку.Работает нормально после переноса библиотеки mjs.

...