Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import not working with JavaScript in PhpStorm/Webstorm

I'm trying to run a piece of JavaScript code written in a tutorial that looks like this:

main.js

import Vue from 'Vue'; import Alert from './components/Alert.vue';  new Vue({     el: 'body',      components: { Alert } }) 

However, PhpStorm is giving the following error:

Import declarations are not supported by current JavaScript version

How I can get a newer(?) JavaScript version in PhpStorm? Is that really the problem here?

like image 561
Bryan Miller Avatar asked Mar 29 '16 21:03

Bryan Miller


People also ask

Does PhpStorm support JavaScript?

With PhpStorm, you can develop modern web, mobile, and desktop applications with JavaScript and Node. js. PhpStorm also supports React, Angular, Vue. js, and other frameworks and provides tight integration with various tools for web development.

How do I run JavaScript in WebStorm?

To run a script, open it in the editor or select it in the Project tool window, and then select Run <script file name> from the context menu. WebStorm creates a temporary run/debug configuration of the type Node. js. To run a test, click the gutter icon next to it or press Ctrl+Shift+F10 .

Is WebStorm and PhpStorm the same?

NOTE: PhpStorm includes all the functionality of WebStorm (HTML/CSS Editor, JavaScript Editor) and adds full-fledged support for PHP and Databases/SQL. Their forum also has quite few answers for such question.

How do I change the JavaScript version on WebStorm?

Choose the JavaScript language versionIn the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Languages & Frameworks | JavaScript. The JavaScript page opens. From the list, choose one of the supported JavaScript language versions: ECMAScript 5.1.


1 Answers

In your preferences, change the version of javascript to ECMAScript 6.

like image 68
Naftali Avatar answered Nov 13 '22 02:11

Naftali