richb-hanover

react-starter-kit: ERROR in ./src/data/queries/content.js

Feb 29th, 2016
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bash-3.2$ npm start
  2.  
  3. > @ start /Users/richb/github/react-starter-kit-richb
  4. > babel-node tools/run start
  5.  
  6. [22:16:08] Starting 'start'...
  7. [22:16:08] Starting 'clean'...
  8. [22:16:08] Finished 'clean' after 42 ms
  9. [22:16:08] Starting 'bound copy'...
  10. build/package.json
  11. [22:16:08] Finished 'bound copy' after 149 ms
  12. webpack built 422ba140c5b05339f7a8 in 5251ms
  13. Child
  14.     Time: 5251ms
  15.                            Asset     Size  Chunks             Chunk Names
  16.     main.js?422ba140c5b05339f7a8  3.39 MB       0  [emitted]  main
  17. Child
  18.     Time: 4803ms
  19.             Asset    Size  Chunks             Chunk Names
  20.         server.js  228 kB       0  [emitted]  main
  21.     server.js.map  232 kB       0  [emitted]  main
  22.  
  23.     ERROR in ./src/data/queries/content.js
  24.     Module build failed: SyntaxError: /Users/richb/github/react-starter-kit-richb/src/data/queries/content.js: "success" is read-only (This is an error on an internal node. Probably an internal error. Location has been estimated.)
  25.         1 | /**
  26.         2 |  * React Starter Kit (https://www.reactstarterkit.com/)
  27.         3 |  *
  28.         4 |  * Copyright © 2014-2016 Kriasoft, LLC. All rights reserved.
  29.         5 |  *
  30.         6 |  * This source code is licensed under the MIT license found in the
  31.         7 |  * LICENSE.txt file in the root directory of this source tree.
  32.         8 |  */
  33.         9 |
  34.        10 | import fs from 'fs';
  35.        11 | import { join } from 'path';
  36.        12 | import Promise from 'bluebird';
  37.        13 | import jade from 'jade';
  38.        14 | import fm from 'front-matter';
  39.        15 |
  40.        16 | import {
  41.        17 |   GraphQLString as StringType,
  42.        18 |   GraphQLNonNull as NonNull,
  43.        19 | } from 'graphql';
  44.        20 |
  45.        21 | import ContentType from '../types/ContentType';
  46.        22 |
  47.        23 | const md = require('markdown-it')();
  48.        24 |
  49.        25 | // A folder with Jade/Markdown/HTML content pages
  50.        26 | const CONTENT_DIR = join(__dirname, './content');
  51.        27 |
  52.        28 | // Extract 'front matter' metadata and generate HTML
  53.        29 | const parseContent = (path, fileContent, extension) => {
  54.        30 |   const fmContent = fm(fileContent);
  55.        31 |   let htmlContent;
  56.        32 |   switch (extension) {
  57.        33 |     case '.jade':
  58.        34 |       htmlContent = jade.render(fmContent.body);
  59.        35 |       break;
  60.        36 |     case '.md':
  61.        37 |       htmlContent = md.render(fmContent.body);
  62.        38 |       break;
  63.        39 |     case '.html':
  64.        40 |       htmlContent = fmContent.body;
  65.        41 |       break;
  66.        42 |     default:
  67.        43 |       return null;
  68.        44 |   }
  69.        45 |   return Object.assign({ path, content: htmlContent }, fmContent.attributes);
  70.        46 | };
  71.        47 |
  72.        48 | const readFile = Promise.promisify(fs.readFile);
  73.        49 | const fileExists = filename => new Promise(resolve => {
  74.        50 |   fs.exists(filename, resolve);
  75.        51 | });
  76.        52 |
  77.        53 | async function resolveExtension(path, extension) {
  78.        54 |   let fileNameBase = join(CONTENT_DIR, `${path === '/' ? '/index' : path}`);
  79.        55 |   let ext = extension;
  80.        56 |   if (!ext.startsWith('.')) {
  81.        57 |     ext = `.${extension}`;
  82.        58 |   }
  83.        59 |
  84.        60 |   let fileName = fileNameBase + ext;
  85.        61 |
  86.        62 |   if (!(await fileExists(fileName))) {
  87.        63 |     fileNameBase = join(CONTENT_DIR, `${path}/index`);
  88.        64 |     fileName = fileNameBase + ext;
  89.        65 |   }
  90.        66 |
  91.        67 |   if (!(await fileExists(fileName))) {
  92.        68 |     return { success: false };
  93.        69 |   }
  94.        70 |
  95.        71 |   return { success: true, fileName };
  96.        72 | }
  97.        73 |
  98.        74 | async function resolveFileName(path) {
  99.        75 |   const extensions = ['.jade', '.md', '.html'];
  100.        76 |
  101.        77 |   for (const extension of extensions) {
  102.        78 |     const maybeFileName = await resolveExtension(path, extension);
  103.        79 |     if (maybeFileName.success) {
  104.        80 |       return { success: true, fileName: maybeFileName.fileName, extension };
  105.        81 |     }
  106.        82 |   }
  107.        83 |
  108.        84 |   return { success: false, fileName: null, extension: null };
  109.        85 | }
  110.        86 |
  111.        87 | export default {
  112.        88 |   type: ContentType,
  113.        89 |   args: {
  114.        90 |     path: { type: new NonNull(StringType) },
  115.        91 |   },
  116.        92 |   async resolve({ request }, { path }) {
  117.        93 |     const { success, fileName, extension } = await resolveFileName(path);
  118.        94 |     if (!success) {
  119.        95 |       return null;
  120.        96 |     }
  121.        97 |
  122.        98 |     const source = await readFile(fileName, { encoding: 'utf8' });
  123.        99 |     return parseContent(path, source, extension);
  124.       100 |   },
  125.       101 | };
  126.       102 |
  127.         at File.buildCodeFrameError (/Users/richb/github/react-starter-kit-richb/node_modules/babel-core/lib/transformation/file/index.js:431:15)
  128.         at NodePath.buildCodeFrameError (/Users/richb/github/react-starter-kit-richb/node_modules/babel-traverse/lib/path/index.js:150:26)
  129.         at PluginPass.Scope (/Users/richb/github/react-starter-kit-richb/node_modules/babel-plugin-check-es2015-constants/lib/index.js:33:29)
  130.         at PluginPass.newFn (/Users/richb/github/react-starter-kit-richb/node_modules/babel-traverse/lib/visitors.js:326:17)
  131.         at newFn (/Users/richb/github/react-starter-kit-richb/node_modules/babel-traverse/lib/visitors.js:293:19)
  132.         at NodePath._call (/Users/richb/github/react-starter-kit-richb/node_modules/babel-traverse/lib/path/context.js:75:18)
  133.         at NodePath.call (/Users/richb/github/react-starter-kit-richb/node_modules/babel-traverse/lib/path/context.js:47:17)
  134.         at NodePath.visit (/Users/richb/github/react-starter-kit-richb/node_modules/babel-traverse/lib/path/context.js:105:12)
  135.         at TraversalContext.visitQueue (/Users/richb/github/react-starter-kit-richb/node_modules/babel-traverse/lib/context.js:156:16)
  136.         at TraversalContext.visitMultiple (/Users/richb/github/react-starter-kit-richb/node_modules/babel-traverse/lib/context.js:108:17)
  137.         at TraversalContext.visit (/Users/richb/github/react-starter-kit-richb/node_modules/babel-traverse/lib/context.js:198:19)
  138.         at Function.traverse.node (/Users/richb/github/react-starter-kit-richb/node_modules/babel-traverse/lib/index.js:141:17)
  139.         at NodePath.visit (/Users/richb/github/react-starter-kit-richb/node_modules/babel-traverse/lib/path/context.js:115:22)
  140.         at TraversalContext.visitQueue (/Users/richb/github/react-starter-kit-richb/node_modules/babel-traverse/lib/context.js:156:16)
  141.         at TraversalContext.visitMultiple (/Users/richb/github/react-starter-kit-richb/node_modules/babel-traverse/lib/context.js:108:17)
  142.         at TraversalContext.visit (/Users/richb/github/react-starter-kit-richb/node_modules/babel-traverse/lib/context.js:198:19)
  143.         at Function.traverse.node (/Users/richb/github/react-starter-kit-richb/node_modules/babel-traverse/lib/index.js:141:17)
  144.      @ ./src/data/schema.js 14:15-43
  145. webpack: bundle is now VALID.
  146.  
  147. /Users/richb/github/react-starter-kit-richb/build/webpack:/src/data/schema.js:20
  148.       content: require('./queries/content').default,
  149.                        ^
  150. Error: Cannot find module "./queries/content"
  151.     at webpackMissingModule (/Users/richb/github/react-starter-kit-richb/build/webpack:/src/data/schema.js:20:24)
  152.     at Object.module.exports.Object.defineProperty.value (/Users/richb/github/react-starter-kit-richb/build/webpack:/src/data/schema.js:20:24)
  153.     at __webpack_require__ (/Users/richb/github/react-starter-kit-richb/build/webpack:/webpack/bootstrap 28be67f138acd4b95a5f:19:1)
  154.     at Object.<anonymous> (/Users/richb/github/react-starter-kit-richb/build/webpack:/webpack/bootstrap 28be67f138acd4b95a5f:39:1)
  155.     at __webpack_require__ (/Users/richb/github/react-starter-kit-richb/build/webpack:/webpack/bootstrap 28be67f138acd4b95a5f:19:1)
  156.     at /Users/richb/github/react-starter-kit-richb/build/webpack:/webpack/bootstrap 28be67f138acd4b95a5f:39:1
  157.     at Object.<anonymous> (/Users/richb/github/react-starter-kit-richb/build/webpack:/webpack/bootstrap 28be67f138acd4b95a5f:39:1)
  158.     at Module._compile (module.js:398:26)
  159.     at Object.Module._extensions..js (module.js:405:10)
  160.     at Module.load (module.js:344:32)
  161.     at Function.Module._load (module.js:301:12)
  162.     at Function.Module.runMain (module.js:430:10)
  163.     at startup (node.js:141:18)
  164.     at node.js:980:3
Advertisement
Add Comment
Please, Sign In to add comment