kuflash / react-router-sitemap

Generate sitemap.xml by React Router configuration
MIT License
249 stars 57 forks source link

main.styl: Unexpected token #41

Open vadimgubin opened 7 years ago

vadimgubin commented 7 years ago

main.styl: Unexpected token, expected ( (1:8)

1 | @import url('//fonts.googleapis.com/css?family=PT+Sans:400,700&subset=latin,cyrillic') | ^ 2 | 3 | @import 'jeet' 4 | @import 'nib' at Parser.pp$5.raise (//node_modules/babylon/lib/index.js:4246:13) at Parser.pp.unexpected (//node_modules/babylon/lib/index.js:1627:8) at Parser.pp$3.parseExprAtom (//node_modules/babylon/lib/index.js:3468:14) at Parser.parseExprAtom (//node_modules/babylon/lib/index.js:6402:22) at Parser.pp$3.parseExprSubscripts (//node_modules/babylon/lib/index.js:3331:19) at Parser.pp$3.parseMaybeUnary (//node_modules/babylon/lib/index.js:3311:19) at Parser.pp$3.parseExprOps (//node_modules/babylon/lib/index.js:3241:19) at Parser.pp$3.parseMaybeConditional (//node_modules/babylon/lib/index.js:3218:19) at Parser.pp$3.parseMaybeAssign (//node_modules/babylon/lib/index.js:3181:19) at Parser.parseMaybeAssign (//node_modules/babylon/lib/index.js:5694:20)

How to reproduce

"react": "^0.14.8", "react-router": "=2.0.1", "redux-router": "^2.1.2", "style-loader": "^0.13.0", "stylus": "^0.54.5", "stylus-loader": "^2.3.1", "react-router-sitemap": "^1.0.8",

  1. create sitemap-builder.js require('babel-register');

const router = require('./src/router').default; const Sitemap = require('react-router-sitemap').default;

( new Sitemap(router) .build('http://my-site.ru') .save('./sitemap.xml') );

  1. run ' node sitemap-builder.js'
vadimgubin commented 7 years ago

when I added require.extensions['.css','.styl'] = function () { return null; }; into sitemap-builder.js

react-transform-hmr/lib/index.js:51 throw new Error('locals[0] does not appear to be a module object with Hot Module ' + 'replacement API enabled. You should disable react-transform-hmr in ' + 'production by using env section in Babel configuration. See the ' + 'example in README: https://github.com/gaearon/react-transform-hmr'); ^

Error: locals[0] does not appear to be a module object with Hot Module replacement API enabled. You should disable react-transform-hmr in production by using env section in Babel configuration. See the example in README: https://github.com/gaearon/react-transform-hmr

vadimgubin commented 7 years ago

cross-env NODE_ENV=production node sitemap-builder.js resolve it :)

kuflash commented 7 years ago

I know about this problem, but this problem is not of this library. In our projects, I also solves the problem with this code:

require.extensions['.css','.styl'] = function () {
  return null;
};
vadimgubin commented 7 years ago

Yes, but without this library I didn't have this problem. Sitemap generator for single-page React-apps is very helpful. And I hope improve your library by my bug-reports.

ramneet-chopra commented 4 years ago

I am also facing this error but in different context. I tried above mentioned solution but it doesn't work for me. I do not have much experience on babel. I created below babelrc file

{ "ignore": [ "node_modules/*/" ], "presets": [ "@babel/preset-env", "@babel/preset-react" ], "plugins": [ "babel-plugin-react-css-modules", "transform-class-properties", ["module-resolver", { "cwd": "babelrc", "root": ["./src"] }] ] }

And I am getting this error:

/home/ramneet/frontend/src/base_components/Box/styles.css:1 (function (exports, require, module, filename, dirname) { .Box { ^

SyntaxError: Unexpected token . at new Script (vm.js:80:7) at createScript (vm.js:274:10) at Object.runInThisContext (vm.js:326:10) at Module._compile (internal/modules/cjs/loader.js:664:28) at Module._extensions..js (internal/modules/cjs/loader.js:712:10) at Object.newLoader [as .js] (/home/ramneet/frontend/node_modules/pirates/lib/index.js:104:7) at Module.load (internal/modules/cjs/loader.js:600:32) at tryModuleLoad (internal/modules/cjs/loader.js:539:12) at Function.Module._load (internal/modules/cjs/loader.js:531:3) at Module.require (internal/modules/cjs/loader.js:637:17) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! basic@0.1.0 sitemap: node ./sitemap-builder.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the basic@0.1.0 sitemap 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! /home/.npm/_logs/2019-09-24T06_12_41_777Z-debug.log

Any help will be appreciated

kuflash commented 4 years ago

@ramneet-chopra where is you added this is code?

require.extensions['.css','.styl'] = function () {
  return null;
};

Can you show file where calling sitemap generator?