Hi guys!
First, this is my first report here, so I want to thank you guys. Awesome framework 馃憦 馃帀
I've written a module and published in a private npm repository, and have imported it to my nuxt project, but now I'm receiving this error:
Vue.js error
/Users/michaelamaral/dev/cdb/node_modules/@cdb/nexus/index.js:1
(function (exports, require, module, __filename, __dirname) { import doLogin from './modules/doLogin'
^^^^^^
SyntaxError: Unexpected token import
at Object.exports.runInThisContext (vm.js:78:16)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (__vue_ssr_bundle__:3879:18)
at __webpack_require__ (__vue_ssr_bundle__:21:30)
Funny thing: the module structure is '@cdb/nexus'. If i copy the nexus folder and paste in the node_modules, it works perfectly.
Any ideas? 鈽癸笍
Thanks
es6 import is not implemented by node, you need change your code to use the require statement, this is not a nuxt error ;)
Hi @ammichael
As @danieloprado said, the import statement is not supported by node.js (yet).
Can you tell us where do you import your module in your nuxt.js project?
@danieloprado
I thought so, but why it works fine when changing the folder structure?!
Do you know why?
@Atinux
I'm importing in index.vue like this: import { doLogin } from '@cdb/nexus'
@ammichael can you use Webpack to bundle your JS files to avoid any import statement?
This is really weird that it works when changing the folder structure.
@ammichael no idea, sorry :confused:
@Atinux
Probably yeap. Didn't want to add complexity to the module right now, but I think that it is a good way. Thanks!
@danieloprado No problem (:
@ammichael you might want to use backpack, it's a really elegant solution.
@Atinux Dude, this backpack would be perfect! Hahah
But I already set the whole webpack, and it's working fine already. Thanks! (:
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
es6 import is not implemented by node, you need change your code to use the require statement, this is not a nuxt error ;)