Can't find module using absolute path


In my server/main.js I have the following code

import '/imports/startup/server';
import '/imports/startup/both';

Then in my imports/startup/server/index.js I have the following code

import { Meteor } from 'meteor/meteor';
import { render } from 'react-dom';
import { renderRoutes } from '/imports/startup/client/routes.js';

Meteor.startup(() => {
  render(renderRoutes(), document.getElementById('app'));

My routes.js

import React from 'react';
import { Router, Route, Switch } from 'react-router';
import createBrowserHistory from 'history/createBrowserHistory';

// route components
import BodyLayout from '../../ui/layouts/body/body.js';
import NotFoundPage from '../../ui/not-found/not-found.js';

const browserHistory = createBrowserHistory();

export const renderRoutes = () => (
  <Router history={browserHistory}>
      <Route exact path="/" component={BodyLayout}/>
      <Route component={NotFoundPage}/>

But when running it I get the following error, telling me it can’t find the module

Error: Cannot find module '/imports/startup/client/routes.js'
    at makeMissingError (packages\modules-runtime.js:231:12)
    at require (packages\modules-runtime.js:241:19)
    at index.js (imports/startup/server/index.js:1:175)
    at fileEvaluate (packages\modules-runtime.js:343:9)
    at require (packages\modules-runtime.js:238:16)
    at main.js (server/main.js:1:14)
    at fileEvaluate (packages\modules-runtime.js:343:9)
    at require (packages\modules-runtime.js:238:16)
    at C:\meteor\laevis\.meteor\local\build\programs\server\app\app.js:65:1
    at C:\meteor\laevis\.meteor\local\build\programs\server\boot.js:411:36
    at Array.forEach (<anonymous>)
    at C:\meteor\laevis\.meteor\local\build\programs\server\boot.js:220:19
    at C:\meteor\laevis\.meteor\local\build\programs\server\boot.js:471:5
    at (C:\meteor\laevis\.meteor\local\build\programs\server\profile.js:510:12)
    at C:\meteor\laevis\.meteor\local\build\programs\server\boot.js:470:11
Exited with code: 1
Your application is crashing. Waiting for file change.

The file clearly exists so I don’t know what possibly could be wrong, especially since I’m using an absolute path… any help?
PS: I’m using meteor on Windows 10.


As an extra protection, any file in a client folder can’t be imported from the server, and vice-versa.

If it’s supposed to run on both, you’ll need to take it out of the client folder

1 Like

Did you find any solutions to this? I got this error in latest version


@sasikanth123 if you’re still having an issue with this, you should open a new thread since this is usually project dependent.

Also have a read through this page of the Meteor guide:

1 Like