search

Home  >  Q&A  >  body text

node.js - How to solve the problem that nodejs on Alibaba Cloud does not support import, and the project reports Unexpected token import after npm run build

1. The problem is as the title says. After deploying the vue project, everything goes fine when npm run dev is executed, but an error keeps reporting after npm run build is executed.

2. My Alibaba Cloud The operating system is ubuntu and the node version is 6.1.0
3. After searching online, it seems that the nodejs6 version does not support import, but why does nodejs on my local computer not report an error?
4. Please give us your suggestions, thank you all!

仅有的幸福仅有的幸福2713 days ago1058

reply all(3)I'll reply

  • 高洛峰

    高洛峰2017-06-20 10:08:58

    node6 does not support import syntax, solution:
    1. Change import to require
    2. Update node to 8.0

    reply
    0
  • 怪我咯

    怪我咯2017-06-20 10:08:58

    I have encountered a similar problem. I have no problem packaging with mac, but there is a problem with window packaging. I suspect it is a problem with the npm version, because the node version of mac is the same as the node version of window, but npm is different. Mac is 3.xxx, window is 4.xx

    reply
    0
  • 某草草

    某草草2017-06-20 10:08:58

    node6 does not support import syntax. You should post package.json and part of the code

    reply
    0
  • Cancelreply