Unexpected token import - first build
See original GitHub issueNode version: 6.9.5
npm version: 3.10.10
Operating system: Windows 10
Command line used: Git Bash
Steps to reproduce:
- Clone the project
- Run
npm install
- Run
npm run setup
- Error appears
(function (exports, require, module, __filename, __dirname) { import { chalkSuccess } from './chalkConfig';
^^^^^^
SyntaxError: Unexpected token import
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at loader (C:\Users\{project folder}\node_modules\babel-register\lib\node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (C:\Users\{project folder}\node_modules\babel-register\lib\node.js:154:7)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Function.Module.runMain (module.js:604:10)
at C:\Users\{project folder}\node_modules\babel-cli\lib\_babel-node.js:159:24
at Object.<anonymous> (C:\Users\{project folder}\node_modules\babel-cli\lib\_babel-node.js:160:7)```
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Node.js - SyntaxError: Unexpected token import - Stack Overflow
Use transpiler like Babel to use import in Nodejs as it is not natively supported in nodejs.There is best alternative of import is...
Read more >Unexpected token import Error in TypeScript | bobbyhadz
To solve the Uncaught SyntaxError: Unexpected token import in TypeScript, set the `module` option to `commonjs` in your `tsconfig.json` file and make sure ......
Read more >Unexpected token Identifier error - Import OpenLayers
This form is inteneded for development environment (like node.js and npm ), where you can run it uncompiled and then has to compiled...
Read more >How I Fixed The Unexpected Token Error In Jest
Jest encountered an unexpected token. Depending upon your setup, you might see the error on the first line of the code file or...
Read more >Cant build my vuejs app on production but can locally ... - Reddit
import { performance } from 'node:perf_hooks'. ^. SyntaxError: Unexpected token {. at Module._compile (internal/modules/cjs/loader.js:721:23).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I confirmed that the file was there.
I found the reason why in case anyone else comes across this issue. It is specifically a problem with windows machines I believe. I tried the setup on my Ubuntu box and it works fine.
When working with windows you need to have the following installed
npm install --save-dev cross-env
.The reason behind this is that the
NODE_ENV
var on my machine was set to production and I was unable to set it to development without that module. Once installed and theNODE_ENV=development
command was run everything worked out ok.oh wow, ok thanks! I think once I uninstalled the demo project it took my babel away and I was lost 😢.