Giter VIP home page Giter VIP logo

Comments (19)

waltfy avatar waltfy commented on May 18, 2024 1

@SpaceK33z @monolithed I think it makes sense to close the issue. I'll post any useful information I find here, it'll maybe help other people. Thanks!

👍

from json-loader.

dsebastien avatar dsebastien commented on May 18, 2024 1

I'm getting the following error when loading json files with Webpack 2 and this plugin (which I don't have with Webpack 1.x:

�[1m�[31mERROR in ./src/stark-app-config.json
Module build failed: SyntaxError: Unexpected token m
    at Object.parse (native)
    at Object.module.exports (C:\LocalData\DEV\Workspace\AAH-Stark\node_modules\json-loader\index.js:7:48)
 @ ./src/app/modules/config/module.ts 12:21-62
 @ ./src/app/modules/index.ts
 @ ./src/app/app.ts
 @ ./src/main.ts
 @ multi main�[39m�[22m

Any ideas? I guess the 'm' in error is part of "module.exports" or something like that.

from json-loader.

SpaceK33z avatar SpaceK33z commented on May 18, 2024

I'm using json-loader with webpack v2 and it's working for me. Do you use extract-text-webpack-plugin, and if so, what version?

from json-loader.

monolithed avatar monolithed commented on May 18, 2024

Do you use extract-text-webpack-plugin, and if so, what version?

Yep, webpack@^2.1.0-beta.25 and extract-text-webpack-plugin@^2.0.0-beta.4

All dependencies

{
    "dependencies": {
        "camelcase": "^3.0.0",
        "normalize.css": "^4.2.0",
        "debug": "^2.2.0",
        "decko": "^1.1.3",
        "fuse.js": "2.5.0",
        "react": "^15.3.2",
        "react-dom": "^15.2.1",
        "react-redux": "^4.4.5",
        "react-iframe": "^0.0.4",
        "react-addons-css-transition-group": "^15.3.2",
        "react-bem-helper": "^1.1.0",
        "redux": "^3.0.5"
    },

    "devDependencies": {
        "chrome-stub": "1.5.0",

        "autoprefixer": "^6.5.1",
        "precss": "^1.4.0",
        "enzyme": "^1.1.3",

        "istanbul-instrumenter-loader": "^0.1.3",
        "babel-preset-airbnb": "^1.0.1",
        "babelify": "^7.2.0",
        "browserify": "^13.0.0",
        "babel-runtime": "^6.3.19",
        "babel-plugin-espower": "2.3.1",
        "karma": "^1.3.0",
        "karma-mocha": "^1.2.0",
        "karma-coverage": "^1.1.1",
        "karma-webpack": "^1.8.0",
        "karma-spec-reporter": "0.0.26",
        "karma-sourcemap-loader": "0.3.7",
        "karma-phantomjs-launcher": "1.0.2",
        "karma-babel-preprocessor": "6.0.1",
        "karma-browserify-preprocessor": "0.2.0",
        "mocha": "^3.1.2",
        "phantomjs-prebuilt": "2.1.13",

        "babel-core": "^6.17.0",
        "babel-loader": "^6.2.5",
        "babel-eslint": "7.0.0",
        "babel-preset-es2015": "^6.16.0",
        "babel-preset-es2016": "^6.16.0",
        "babel-preset-es2017": "^6.16.0",
        "babel-preset-react": "^6.16.0",
        "babel-preset-react-hmre": "1.1.1",
        "babel-plugin-transform-object-rest-spread": "6.8.0",
        "babel-plugin-transform-decorators-legacy": "1.3.4",
        "babel-plugin-transform-react-remove-prop-types": "0.2.10",

        "isparta": "^4.0.0",
        "express": "^4.13.3",

        "eslint": "^3.8.1",
        "eslint-loader": "^1.6.0",
        "eslint-config-pobedit": "^0.0.5",
        "eslint-friendly-formatter": "^2.0.6",
        "eslint-plugin-react": "^6.4.1",
        "eslint-plugin-babel": "^3.3.0",

        "react-addons-test-utils": "^15.3.2",

        "react-transform-hmr": "^1.0.4",
        "react-dev-utils": "^0.2.1",
        "redux-devtools": "^3.3.1",
        "redux-devtools-dock-monitor": "^1.1.1",
        "redux-devtools-log-monitor": "^1.0.11",
        "redux-devtools-inspector": "^0.8.0",
        "redux-logger": "^2.2.1",
        "redux-thunk": "^2.1.0",
        "redbox-react": "^1.2.10",
        "react-transform-catch-errors": "^1.0.2",

        "webpack": "^2.1.0-beta.25",
        "webpack-dev-middleware": "^1.2.0",
        "webpack-hot-middleware": "^2.2.0",
        "webpack-bundle-size-analyzer": "2.2.0",
        "webpack-visualizer-plugin": "0.1.5",
        "clean-webpack-plugin": "^0.1.13",
        "unused-files-webpack-plugin": "^3.0.0",
        "extract-text-webpack-plugin": "^2.0.0-beta.4",
        "optimize-css-assets-webpack-plugin": "^1.3.0",
        "imports-loader": "^0.6.5",
        "json-loader": "0.5.4",
        "find-cache-dir": "0.1.1",
        "stats-webpack-plugin": "0.4.2",
        "postcss-loader": "^0.9.1",
        "postcss-import": "^8.1.2",
        "base64-inline-loader": "^0.0.1",
        "css-loader": "^0.23.0",
        "style-loader" : "^0.13.0"
    }
}

from json-loader.

waltfy avatar waltfy commented on May 18, 2024

@monolithed have you found a workaround for this yet? Let me know if I can help in any way!

from json-loader.

waltfy avatar waltfy commented on May 18, 2024

@SpaceK33z seems like removing the requirement for extract-text-webpack-plugin seems to resolve the issues for json-loader — do you have more context?

from json-loader.

SpaceK33z avatar SpaceK33z commented on May 18, 2024

@waltfy it might be related to webpack-contrib/extract-text-webpack-plugin#265, but not sure.

from json-loader.

monolithed avatar monolithed commented on May 18, 2024

@SpaceK33z

I'm using json-loader with webpack v2 and it's working for me.

Have you tried to delete your node_modules before?

@waltfy

have you found a workaround for this yet? Let me know if I can help in any way!

I rolled to a previous version 😄

from json-loader.

SpaceK33z avatar SpaceK33z commented on May 18, 2024

Jep, just tried it again. What version of which package did you rollback to? And does the problem disappear if you don't use extract-text-webpack-plugin?

from json-loader.

monolithed avatar monolithed commented on May 18, 2024

@SpaceK33z, I meant "webpack": "^1.13.2", "json-loader": "0.5.4" :)

from json-loader.

SpaceK33z avatar SpaceK33z commented on May 18, 2024

Okay, but could you checkout if it happens without extract-text-webpack-plugin? This is crucial for me to know because if so, it is probably an issue with extract-text-webpack-plugin.

from json-loader.

monolithed avatar monolithed commented on May 18, 2024

Okay, but could you checkout if it happens without extract-text-webpack-plugin?

Alas, I did not keep that state in the history of commits, sorry.

from json-loader.

SpaceK33z avatar SpaceK33z commented on May 18, 2024

I'm going to close this since webpack v2 with json-loader does work, but it is some other package (probably extract-text-webpack-plugin since that fixed it for @waltfy) that introduces this bug.

from json-loader.

samhh avatar samhh commented on May 18, 2024

I'm getting the exact same as @dsebastien.

from json-loader.

crebuh avatar crebuh commented on May 18, 2024

I've got the same error:

Uncaught Error: Module build failed: SyntaxError: Unexpected token m
    at Object.parse (native)
    at Object.module.exports (/home/Projects/app/node_modules/json-loader/index.js:7:48)

I'm using node in version 4.6.0

from json-loader.

SpaceK33z avatar SpaceK33z commented on May 18, 2024

Okay I'll reopen this, but please provide some useful information so we can narrow this down. Try to remove as many plugins / loaders as possible. Especially try if removing extract-text-webpack-plugin works.

from json-loader.

crebuh avatar crebuh commented on May 18, 2024

I changed my webpack.config config a bit and now it is working again. In the webpack.config I'm now using:

{ test: /\.json$/, loader: 'json-loader' }

and in my files instead of importing the files like this before:

  const routesForBreadcrumb = require('json!../../config/routes.json');

I had to remove the json! at the beginning of the path like

  const routesForBreadcrumb = require('../../config/routes.json');

now it is working in node as well as in the browser environment

from json-loader.

SpaceK33z avatar SpaceK33z commented on May 18, 2024

@crebuh see webpack/webpack#3359 for a plan on how we want to avoid the issue you had from happening again.

Closing this again since you can fix that error with the above fix.

from json-loader.

dsebastien avatar dsebastien commented on May 18, 2024

In my case, I've doubled checked but I didn't specify the "json!" in the require call, so normally I'm only using the loader once...

from json-loader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.