DEV Community

Cover image for after build succeeded, I tried to run it locally but got this error :
ismailalabou
ismailalabou

Posted on

after build succeeded, I tried to run it locally but got this error :

$ npm run start

ismailalabou.github.io@0.1.0 start C:\Users\ismailalabou\Documents\Gitlab\portfolio
node src/index.js

(node:10340) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use node --trace-warnings ... to show where the warning was created)
C:\Users\ismailalabou\Documents\Gitlab\portfolio\src\index.js:1
import React from "react";
^^^^^^

SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint as runMain
at internal/main/run_main_module.js:17:47
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ismailalabou.github.io@0.1.0 start: node src/index.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ismailalabou.github.io@0.1.0 start 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! C:\Users\ismailalabou\AppData\Roaming\npm-cache_logs\2020-12-20T11_10_28_952Z-debug.log

Top comments (8)

Collapse
 
maciejtrzcinski profile image
Maciej Trzciński 🌱🇵🇱 • Edited

Hi,

Add

"type": "module"
Enter fullscreen mode Exit fullscreen mode


in your package.json

Collapse
 
alb_isma profile image
ismailalabou

it's there ...

Collapse
 
alb_isma profile image
ismailalabou

it's already there it says: Module 'type is extraneous npm [10, 3]'

Collapse
 
janpauldahlke profile image
jan paul

here are the related docs:
developer.mozilla.org/en-US/docs/W...

Collapse
 
alb_isma profile image
ismailalabou

it's there ...

Thread Thread
 
alb_isma profile image
ismailalabou

"version": "0.1.0",
"private": true,
"type": "module",
"engines": {
"node": "14.15.0",
"npm": "6.14.8"
},

Collapse
 
alb_isma profile image
ismailalabou

it's already there it says: Module 'type is extraneous npm [10, 3]'

Collapse
 
alb_isma profile image
ismailalabou

help me solve this <3