sveltejs/template

Unexpected token import error when using npm run dev

naweddiwan opened this issue · 2 comments

svelte|⇒ npx degit sveltejs/template my-svelte-project
npx: installed 1 in 1.695s
> cloned sveltejs/template#HEAD to my-svelte-project
svelte|⇒ cd my-svelte-project 
my-svelte-project|⇒ npm install
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN ws@7.4.4 requires a peer of bufferutil@^4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN ws@7.4.4 requires a peer of utf-8-validate@^5.0.2 but none is installed. You must install peer dependencies yourself.

added 97 packages from 132 contributors and audited 97 packages in 4.204s
found 0 vulnerabilities

my-svelte-project|⇒ npm run dev

> svelte-app@1.0.0 dev /Users/naweddiwan/Desktop/Study/svelte/my-svelte-project
> rollup -c -w

/Users/naweddiwan/Desktop/Study/svelte/my-svelte-project/node_modules/rollup/dist/shared/loadConfigFile.js:494
        ? (await import(url.pathToFileURL(fileName).href)).default
                 ^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/naweddiwan/Desktop/Study/svelte/my-svelte-project/node_modules/rollup/dist/bin/rollup:22:25)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! svelte-app@1.0.0 dev: `rollup -c -w`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the svelte-app@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/naweddiwan/.npm/_logs/2021-04-15T14_52_30_330Z-debug.log
my-svelte-project|⇒ 

System info:
Macbook Pro 16" 2019 - intel i9 running latest BigSur(11.2.3)

Seems like it was node version that was causing the error.
previously it was 8.12.0.
I switched to 14.5.1 and it worked.