我正在使用Nuxt @ 2 build.transpile
选项(https://nuxtjs.org/api/configuration-build#transpile):
nuxt.config.js
build: {
transpile: [
'@namespace/node-module-name/file.js'
]
}
不幸的是,在构建时仍然出现错误:
✖ error /Users/me/project/node_modules/@namespace/node-module-name/file.js:1
(function (exports, require, module, __filename, __dirname) { import createAPI from '@namespace/api';
^^^^^^
SyntaxError: Unexpected token import
nuxt babel配置能够用umd,commonjs等替换import
吗?
答案 0 :(得分:0)
代替:
import createAPI from '@namespace/api'
请尝试以下操作:
const createAPI = require('@namespace/api')