question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SyntaxError: Unexpected token (package.json) with Webpack

See original GitHub issue

ERROR in Entry module not found: SyntaxError: D:\ProjectPath\package.json (directory description file): SyntaxError: Unexpected token

webpack.config.js

module.exports = {
    context: __dirname,
    entry: 'main.ts',
    output: {
        path: __dirname + '/Builds/js',
        filename: 'all.js'
    },
    resolve: {
        extensions: ['', '.js', '.ts']
    },
    module: {
        loaders: [
          {
              test: /\.ts$/,
              loader: 'ts'
          },
          {
              test: /\.json$/,
              loader: "json"
          }
        ]
    }
};

package.json

{
    "version": "1.0.0",
    "name": "RevenueTracker",
    "description": "A angular 2 app",    
    "scripts": {
        "build": "webpack",
        "typings": "typings",
        "preinstall": "npm i -g bower",
        "postinstall": "typings install"
    },
    "dependencies": {
        "jquery": "~1.11.3",
        "@angular/common": "2.0.0-rc.1",
        "@angular/compiler": "2.0.0-rc.1",
        "@angular/core": "2.0.0-rc.1",
        "@angular/http": "2.0.0-rc.1",
        "@angular/platform-browser": "2.0.0-rc.1",
        "@angular/platform-browser-dynamic": "2.0.0-rc.1",
        "@angular/router": "2.0.0-rc.1",
        "@angular/router-deprecated": "2.0.0-rc.1",
        "@angular/upgrade": "2.0.0-rc.1",
        "systemjs": "0.19.26",
        "es6-shim": "^0.35.0",
        "reflect-metadata": "0.1.2",
        "rxjs": "5.0.0-beta.6",
        "zone.js": "^0.6.12",
        "highcharts": "^4.2.3",
        "ng2-highcharts": "^0.3.4",
        "moment": "^2.13.0"
    },
    "devDependencies": {
        "typescript": "^1.8.0",
        "typings": "^0.7.12",
        "gulp": "3.9.0",
        "gulp-bower": "^0.0.13",
        "gulp-uglify": "1.5.1",
        "gulp-concat": "2.6.0",
        "gulp-sourcemaps": "1.6.0",
        "require-dir": "0.3.0",
        "webpack": "^1.12.14",
        "webpack-merge": "^0.9.0",
        "file-loader": "^0.8.5",
        "ts-loader": "^0.8.1",
        "json-loader": "0.5.4"
    }
}

I don’t find any syntax error in package.json I am trying from a long time but the same error exist. You will notice i have given absolute path for the entry as

entry: ‘main.ts’,

when i give relative path (entry: ‘./main’) it gives error ERROR in Entry module not found: Error: Cannot resolve ‘file’ or ‘directory’ ./main in D:\ProjectPath

Then it resolves the path for main.ts and finally gives the error as mentioned above. ERROR in Entry module not found: SyntaxError: D:\ProjectPath\package.json (directory description file): SyntaxError: Unexpected token

This is very strange behavior. Please let me know if anybody found same issue and how did u resolve?

Thank you.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:19 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
Vertygocommented, May 16, 2017

@blackcloud2333 try to:

  1. copy content of package.json (skip the first line since from the error message I would say there is some special character hidden in the beginning of the file)
  2. remove package.json
  3. create new package.json file and paste content (retype first line)
3reactions
vlodkocommented, Feb 10, 2017

Having same issue when using yarn instead of npm.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack Build SyntaxError: Unexpected token - Stack Overflow
Just remove the styles import. import "./style.css". Webpack speaks JavaScript, not css, if you want it to learn it you need to create...
Read more >
"SyntaxError: Unexpected token ." in webpack script · Issue #64
Hello, I have the following configuration: node 10.16.0 electron 3.0.2 webpack 4.20.2 webpack-node-externals 1.7.2 When adding the line ...
Read more >
Syntax Error: Unexpected token while bundling with webpack
Greetings, My question is related to configuration of babel/webpack to be able to use nodeJS modules - and unrelated to K6 as such....
Read more >
Webpack lesson - Uncaught SyntaxError: Unexpected token ...
Why do I get "Uncaught SyntaxError: Unexpected token import"? Compiling works ok. I am doing this lessons https://laracasts.com/series/webpack-for-everyone/ ...
Read more >
syntaxerror: unexpected token 'n', "not found" is not valid json
So I had this same error when I installed npm gh-pages. My solution was to delete the Homepage link in package.json and it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found