Issue: The npm module 'moment' cannot be located

My Meteor app works flawlessly on localhost, but when deployed to a remote heroku server, I encounter these errors.

(I am following this)

Any suggestions on how to resolve this issue?

2016-09-09T13:26:02.533532+00:00 heroku[web.1]: Starting process with command `.meteor/heroku_build/bin/node .meteor/heroku_build/app/main.js`
2016-09-09T13:26:06.806440+00:00 heroku[web.1]: Process exited with status 1
2016-09-09T13:26:06.813921+00:00 heroku[web.1]: State changed from starting to crashed
2016-09-09T13:26:06.704013+00:00 app[web.1]: /app/.meteor/heroku_build/app/programs/server/node_modules/fibers/future.js:280
2016-09-09T13:26:06.704027+00:00 app[web.1]:                        throw(ex);
2016-09-09T13:26:06.704028+00:00 app[web.1]:                        ^
2016-09-09T13:26:06.704031+00:00 app[web.1]: Error: Can't find npm module 'moment'. Did you forget to call 'Npm.depends' in package.js within the 'modules-runtime' package?
2016-09-09T13:26:06.704032+00:00 app[web.1]:     at Object.Npm.require (/app/.meteor/heroku_build/app/programs/server/boot.js:198:17)
2016-09-09T13:26:06.704035+00:00 app[web.1]:     at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:82:1)
2016-09-09T13:26:06.704036+00:00 app[web.1]:     at Array.forEach (native)

If I log onto Heroku with heroku run bash, I see the following in /app/typings/globals:

es6-collections  es6-promise  google-maps  google.maps  meteor  moment

This matches what is on my Windows localhost:

https://i.sstatic.net/ABhi6.png

The 'moment' modules are also present in node_modules

https://i.sstatic.net/wKCX3.png

Here is the content of

my node_modules\moment\package.js
:

var profile = {
    resourceTags: {
        ignore: function(filename, mid){
            // only include moment/moment
            return mid != "moment/moment";
        },
        amd: function(filename, mid){
            return /\.js$/.test(filename);
        }
    }
};

My package.json:

{
   ... 
  "dependencies": {
    "@angular/common": "^2.0.0-rc.4",
    ...
    "zone.js": "^0.6.12"
  },

Logs snippet during deployment:

remote: -----> Building Meteor app with ROOT_URL: https://git.heroku.com/remote-thewhozoo.git
...

index.d.ts module for 'moment':

declare module 'moment' {
    var moment: moment.MomentStatic;
    export = moment;
}

I have symbolic links in the root of the Meteor project:

https://i.sstatic.net/I0tsM.png

UPDATE

I believe I've identified the problem, but not sure how to fix it yet.

The issue seems to be that symbolic links point to directories existing locally but not on the remote server.

https://i.sstatic.net/2fcfo.png

UPDATE

I removed all symbolic links and placed the files instead, redeployed, but still getting the same error when the server attempts to start:

2016-09-11T15:23:06.155551+00:00 heroku[web.1]: State changed from crashed to starting
...

Any suggestions please?

I ran: meteor npm install --save

In boot.js, I found this code, but unsure about the author's intent:

    try {
      return require(name);
    } catch (e) {
      ...
      }

UPDATE

I removed the .gitignore file of node_modules/, and now no longer encountering any errors.

https://i.sstatic.net/jXoRL.png

However, being new to Meteor, I'm unsure how to test this. When trying to access the app via

http://remote-thewhozoo.herokuapp.com/
or
https://remote-thewhozoo.herokuapp.com/
, I receive a 404 error:

2016-09-11T16:20:15.183895+00:00 heroku[router]: at=info method=GET path="/sockjs/info?cb=jwgw2yuvgl" host=remote-thewhozoo.herokuapp.com request_id=a49fafb2-9708-46d2-8117-2c789bfa6a3e fwd="105.186.215.147" dyno=web.1 connect=1ms service=2ms status=404 bytes=132

https://i.sstatic.net/7ZUPP.png

I verified the Mongo Database has the collections created by my app. So the Meteor application must be running, just figuring out how to access it.

https://i.sstatic.net/yx09c.png

Any thoughts on this?

Answer №1

Ensure that the following line is included in your package.json file: "moment": "^2.14.1". After confirming, execute the command npm install

Answer №2

Have you given meteor npm install a shot at your project's root directory?

In case moment isn't showing up in the list, have you attempted meteor npm install --save moment?

If not, would you mind sharing your package.js file? You can find it in app/programs/server/

Answer №3

It seems like the issue could be related to your buildpack configuration. I recommend checking out this helpful guide for deploying Meteor apps on Heroku:

Answer №4

After running "npm install moment react-moment", the installation was successful. Interestingly, I encountered errors when attempting to install this package through the official npm site using both methods provided.

Answer №5

If you encounter the issue of

"Cannot find module 'moment'"
, the solution is to install the moment package by navigating to your project's root directory in the terminal and executing the command: npm i moment. After installation, make sure to restart both your IDE and development server for the changes to take effect.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Implement the map function to validate every input and generate a border around inputs that are deemed invalid or empty upon button click

Currently, I'm in the process of developing a form with multiple steps. At each step, when the next button is clicked, I need to validate the active step page using the map function. My goal is to utilize the map function to validate every input and ...

Converting an Express application to Meteor

After working on porting a basic Express-based app to Meteor, I found a helpful post discussing the process of converting an express app to meteor. It involved using a waiter function to wrap iron-router routes that Meteor expects into req / res that Expre ...

Retrieving the values of multiple selected options from various select fields simultaneously

Picture having a dynamic number of select fields (the value of this variable is not fixed). I am looking to extract the values of the selected option from each select field using jQuery (or vanilla JavaScript). This is my approach: var cars = $(".sele ...

The webpage becomes unresponsive due to an Ajax request

Creating a generic way to call ajax requests on my webpage has been challenging. I've developed an extension method for calling post requests asynchronously. $.tiqPost = function(action,data,callback) { alert('Posting...'); $.fancyb ...

Is there a way to determine if a specific string matches a value within an object?

Within my codebase, there exists an object named "codes": var codes = { code1: 'test1' code2: 'test2' } I am looking to determine if this object possesses a specific property and then display the result in the console. if(inp ...

Trigger the onClick event when programmatically setting it as unchecked

My issue involves resetting a form when the user uses the browser's back-button. The form consists of multiple checkboxes, each with its own onClick event. Here is an example of one such checkbox: <input onclick="GetSelectedAmount();" class="Payme ...

``I am experiencing difficulties with utilizing a personalized color scheme in React JS with Material

I'm currently working on customizing the color palette for my project, but I am only able to modify the main attribute and not others. My development environment is JavaScript with MUI, not Typescript. import './App.css'; import {BrowserRout ...

Unable to connect to node.js webserver using the godaddy shared hosting URL

Upon entering www.example.com:3000 into my browser, I am encountering the following error message (where 'example' represents my domain name) This site can't be reached - www.example.com took too long to respond. I have taken the following ...

How can we identify if a React component is stateless/functional?

Two types of components exist in my React project: functional/stateless and those inherited from React.Component: const Component1 = () => (<span>Hello</span>) class Component2 extends React.Component { render() { return (<span> ...

Error: The post method in $setup is not defined in Vue Composition API

Dealing with a frustrating issue in my Vue application. One page is functioning perfectly fine, while the other is causing trouble by displaying this error: The first page loads a collection of wordpress posts (Blog.vue) without any issues, but the second ...

Is there a way to shut down a browser tab without being asked, "Are you sure you want to close this window"?

Is there a way to gracefully close a browser window without being interrupted by the annoying Do you want to close this window prompt? I've noticed that whenever I attempt to use the window.close(); function, this prompt always pops up. ...

The debate between importing images and including them inline in NextJS is a hot

When using NextJS, what sets apart importing an image from directly including it with next/image? import logo from './logo.png'; <Image src={logo} /> /* versus */ <Image src={'/logo.png'} /> (This is pseudocode meant for ...

The vanishing AJAX button

Currently, I am working on a web app in Laravel that includes a simple textarea within a form. This form allows users to input basic markdown text, and my goal is to display the data with both HTML tags and normal formatting. However, I encountered an issu ...

Identify all elements that possess a specific attribute with a precise value in jQuery, and return either true or false

I'm having a slight issue with jQuery. Below is the code in question: if ($("select[rendelo='" + rendelo + "'][nap='" + nap + "'][napszak='" + napszak + "']").val() == 0) { alert('sth'); ...

Ensuring uniform sizing of anchor text using jQuery

My goal is to creatively adjust the font size of anchor text within a paragraph, making it appear as though the text is moving towards and away from the viewer without affecting the surrounding paragraph text. Currently, I am encountering an issue where th ...

Using Javascript to validate passwords and Bootstrap for design enhancements

I've been working on learning Javascript and some basic HTML using bootstrap v5 recently. One of the tasks I'm currently tackling is creating a Sign-in form and implementing validation for the required fields. While following the Bootstrap docu ...

Compilation issue detected when running ng serve

When attempting to run my local server with ng serve, I encountered the following error message: [error] Error: NGCC failed. at NgccProcessor.process (/home/geoffroy/Documents/1_projets_persos/35_ngodt/ngodt-front/node_modules/@ngtools/webpack/src/ngcc ...

Adding a new value to an array of objects without altering the existing values in ReactJS and NextJS

I have a JSON file containing image names that I need to organize into a Key-Value Object. I am currently using regex to create keys by removing "-img[image No]". However, I am having trouble storing all the image names in the array without overwriting pre ...

What is the best way to retrieve the value from a textfield in one module and use it in a

How can I access the value of a textField in another module within React.js without importing the entire textfield component? What is the most effective approach to get access to the value variable in a different module? Below is a sample functional textF ...

TypeScript - Indexable Type

Here is an explanation of some interesting syntax examples: interface StringArray { [index: number]: string; } This code snippet defines a type called StringArray, specifying that when the array is indexed with a number, it will return a string. For e ...