错误:无法找到npm模块'时刻' [英] Error: Can't find npm module 'moment'

查看:498
本文介绍了错误:无法找到npm模块'时刻'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在本地主机上完美运行的Meteor应用程序,但是当我将它部署到远程 heroku 服务器时,出现以下错误。



(我正在实施



矩也存在于 node_modules





这是我的node_modules \moment \package.js

  var profile = {
resourceTags:{
ignore:function(filename,mid){
//只包含时刻/时刻
return mid!=时刻/时刻;
},
amd:function(filename,mid){
return /\.js$/.test(filename);
}
}
};

我的 package.json

  {
dependencies:{
@ angular / common:^ 2.0.0-rc。 4,
@ angular / compiler:^ 2.0.0-rc.4,
@ angular / core:^ 2.0.0-rc.4,
@ angular / forms:^ 0.2.0,
@ angular / http:^ 2.0.0-rc.4,
@ angular / platform-b​​rowser: ^ 2.0.0-rc.4,
@ angular / platform-b​​rowser-dynamic:^ 2.0.0-rc.4,
@ ionic / cloud-angular: ^ 0.4.0,
angular2-meteor:^ 0.6.2,
angular2-moment:^ 0.8.2,
es6-shim :^ 0.35.0,
ionic-angular:^ 2.0.0-beta.11,
ionic-native:1.3.2,
ionicons:3.0.0,
meteor-client-side:^ 1.3.4,
moment:^ 2.14.1,
reflect-元数据:^ 0.1.3,
rxjs:5.0.0-beta.6,
socket.io:^ 1.4.8,
zone.js:^ 0.6.12
},

部署:

  remote:----->使用ROOT_URL构建Meteor应用程序:https://git.heroku.com/remote-thewhozoo.git 
remote:server / collections.ts(1,21):找不到模块'meteor / mongo'。
remote:server / collections.ts(2,29):找不到'api / models'模块。
remote:server / methods.ts(1,22):找不到模块'meteor / meteor'。
remote:server / methods.ts(2,28):无法找到模块'流星/检查'。
remote:server / main.ts(1,25):无法找到模块'时刻'。
remote:server / main.ts(2,22):找不到模块'meteor / meteor'。
remote:
remote:无法解析某些模块:
remote:
remote:moment在/tmp/build_29ec6195d953bd56c0670f7d9ee489a4/server/main.js
remote: (os.linux.x86_64)
remote:
remote:如果您发现与这些缺失模块相关的问题,请考虑运行:
remote:
remote:meteor npm install --save时刻
远程:
远程:----->将建成的slug移动到/tmp/build_29ec6195d953bd56c0670f7d9ee489a4/.meteor/heroku_build/app
remote:----->在构建的slug上安装npm生产依赖关系
remote:
remote:> fibers@1.0.13 install /tmp/build_29ec6195d953bd56c0670f7d9ee489a4/.meteor/heroku_build/app/programs/server/node_modules/fibers
remote:>节点build.js || nodejs build.js
remote:
remote:`linux-x64-v8-4.5` exists;测试
remote:Binary很好;退出
remote:
remote:> meteor-dev-bundle@0.0.0 install /tmp/build_29ec6195d953bd56c0670f7d9ee489a4/.meteor/heroku_build/app/programs/server
remote:>节点npm-rebuild.js
remote:
remote:{
remote:meteor-dev-bundle:0.0.0,
remote:npm: 3.10.6,
remote:ares:1.10.1-DEV,
remote:http_parser:2.7.0,
remote:icu: 56.1,
remote:modules:46,
remote:node:4.5.0,
remote:openssl:1.0.2h,
remote:uv:1.9.1,
remote:v8:4.5.103.37,
remote:zlib:1.2.8
远程:}

index.d.ts

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

我在meteor项目的根目录中有符号链接:





更新



我发现了我认为的问题,但我不是100%确定如何解决它。



问题是符号链接指向本地存在的目录,但不在远程服务器上。





UPDATE



我删除所有符号链接,并且在服务器尝试启动时仍然出现同样的错误:

  2016-09-11T15:23:06.155551 + 00: 00 heroku [web.1]:状态从崩溃改为开始
2016-09-11T15:23:09.146909 + 00:00 heroku [web.1]:用命令`.meteor / heroku_build / bin / node.meteor / heroku_build / app / main .js`
2016-09-11T15:23:13.712742 + 00:00 heroku [web.1]:状态从开始变为崩溃
2016-09-11T15:23:13.640003 + 00:00 app [web.1]:/app/.meteor/heroku_build/app/programs/server/node_modules/fibers/future.js:280
2016-09-11T15:23:13.640048 + 00:00 app [web .1]:throw(ex);
2016-09-11T15:23:13.640073 + 00:00 app [web.1]:^
2016-09-11T15:23:13.640075 + 00:00 app [web.1]:Error :无法找到npm模块'时刻'。您是否忘记在'modules-runtime'包中的package.js中调用'Npm.depends'?
2016-09-11T15:23:13.640076 + 00:00 app [web.1]:在Object.Npm.require(/app/.meteor/heroku_build/app/programs/server/boot.js:198 :17)
2016-09-11T15:23:13.640077 + 00:00 app [web.1]:at options.fallback(packages / modules-runtime / modules-runtime.js:21:1)
2016-09-11T15:23:13.640078 + 00:00 app [web.1]:at meteorInstall.server.main.js(server / main.ts:1:19)
2016-09-11T15 :23:13.640079 + 00:00 app [web.1]:at require(packages / modules-runtime / .npm / package / node_modules / install / install.js:82:1)
2016-09-11T15 :23:13.640079 + 00:00 app [web.1]:at server / main.ts:65:4
2016-09-11T15:23:13.723869 + 00:00 heroku [web.1]:Process退出状态1

有什么想法吗?

<我已经运行: meteor npm install --save



我在 boot.js ,但我不确定作者在做什么。

  try {
return require(name);
} catch(e){
//尝试猜测包名称,以便我们可以打印一个不错的
//错误消息
// fileInfo.path是一个标准路径,使用files.pathSep
var filePathParts = fileInfo.path.split(files.pathSep);
var packageName = filePathParts [1] .replace(/\.js$/,'');

// XXX更好的信息
抛出新错误(
找不到npm模块'+ name +
''。你忘了叫'在''+ packageName +''包中的package.js+
中的'Npm.depends'?);
}

更新
$ b

我删除了 node_modules / .gitignore ,并且我没有收到任何错误现在。





然而,我是新来的流星,所以不知道如何测试这个。但是当我尝试使用 http://remote-thewhozoo.herokuapp.com/ https://remote-thewhozoo.herokuapp调用应用程序时。 com / 我得到一个404错误:

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



我检查Mongo数据库,并且获得了我的应用创建的集合。所以流星必须运行,我只是不知道如何访问它。





有什么想法吗?

解决方案

请确保以下行:时刻:^ 2.14.1是你的package.json
然后运行 npm install


I have a Meteor app that runs perfectly on localhost, but when I deploy it to a remote heroku server, I get the following errors.

(I am implementing this)

Any ideas how to fix this please?

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.704029+00:00 app[web.1]: 
2016-09-09T13:26:06.704030+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.704031+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.704032+00:00 app[web.1]:     at options.fallback (packages/modules-runtime/modules-runtime.js:21:1)
2016-09-09T13:26:06.704032+00:00 app[web.1]:     at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:88:1)
2016-09-09T13:26:06.704033+00:00 app[web.1]:     at meteorInstall.server.main.js (server/main.ts:1:19)
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.704035+00:00 app[web.1]:     at server/main.ts:65:4
2016-09-09T13:26:06.704036+00:00 app[web.1]:     at /app/.meteor/heroku_build/app/programs/server/boot.js:292:10
2016-09-09T13:26:06.704036+00:00 app[web.1]:     at Array.forEach (native)

If I heroku run bash to log onto heroku. In /app/typings/globals I see the following:

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

This seems to match what is on the Windows localhost:

Moments also exist in node_modules

Here is 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",
    "@angular/compiler": "^2.0.0-rc.4",
    "@angular/core": "^2.0.0-rc.4",
    "@angular/forms": "^0.2.0",
    "@angular/http": "^2.0.0-rc.4",
    "@angular/platform-browser": "^2.0.0-rc.4",
    "@angular/platform-browser-dynamic": "^2.0.0-rc.4",
    "@ionic/cloud-angular": "^0.4.0",
    "angular2-meteor": "^0.6.2",
    "angular2-moment": "^0.8.2",
    "es6-shim": "^0.35.0",
    "ionic-angular": "^2.0.0-beta.11",
    "ionic-native": "1.3.2",
    "ionicons": "3.0.0",
    "meteor-client-side": "^1.3.4",
    "moment": "^2.14.1",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.6",
    "socket.io": "^1.4.8",
    "zone.js": "^0.6.12"
  },

snippet from logs when deploying:

remote: -----> Building Meteor app with ROOT_URL: https://git.heroku.com/remote-thewhozoo.git
remote: server/collections.ts (1, 21): Cannot find module 'meteor/mongo'.
remote: server/collections.ts (2, 29): Cannot find module 'api/models'.
remote: server/methods.ts (1, 22): Cannot find module 'meteor/meteor'.
remote: server/methods.ts (2, 28): Cannot find module 'meteor/check'.
remote: server/main.ts (1, 25): Cannot find module 'moment'.
remote: server/main.ts (2, 22): Cannot find module 'meteor/meteor'.
remote:
remote: Unable to resolve some modules:
remote:
remote:   "moment" in /tmp/build_29ec6195d953bd56c0670f7d9ee489a4/server/main.js
remote: (os.linux.x86_64)
remote:
remote: If you notice problems related to these missing modules, consider running:
remote:
remote:   meteor npm install --save moment
remote:
remote: -----> Moving built slug to /tmp/build_29ec6195d953bd56c0670f7d9ee489a4/.meteor/heroku_build/app
remote: -----> Installing npm production dependencies on built slug
remote:
remote: > fibers@1.0.13 install /tmp/build_29ec6195d953bd56c0670f7d9ee489a4/.meteor/heroku_build/app/programs/server/node_modules/fibers
remote: > node build.js || nodejs build.js
remote:
remote: `linux-x64-v8-4.5` exists; testing
remote: Binary is fine; exiting
remote:
remote: > meteor-dev-bundle@0.0.0 install /tmp/build_29ec6195d953bd56c0670f7d9ee489a4/.meteor/heroku_build/app/programs/server
remote: > node npm-rebuild.js
remote:
remote: {
remote:   "meteor-dev-bundle": "0.0.0",
remote:   "npm": "3.10.6",
remote:   "ares": "1.10.1-DEV",
remote:   "http_parser": "2.7.0",
remote:   "icu": "56.1",
remote:   "modules": "46",
remote:   "node": "4.5.0",
remote:   "openssl": "1.0.2h",
remote:   "uv": "1.9.1",
remote:   "v8": "4.5.103.37",
remote:   "zlib": "1.2.8"
remote: }

index.d.ts

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

I do have symbolic links in the root of the meteor project:

UPDATE

I have found the problem I think, but I am not 100% sure how to solve it yet.

The issue is that the symbolic links are pointing to directories that exist locally, but not on the remote server.

UPDATE

I remove all symbolic links, and have the files there instead, deploy, and I still get the same error when the server tries to start:

2016-09-11T15:23:06.155551+00:00 heroku[web.1]: State changed from crashed to starting
2016-09-11T15:23:09.146909+00:00 heroku[web.1]: Starting process with command `.meteor/heroku_build/bin/node .meteor/heroku_build/app/main.js`
2016-09-11T15:23:13.712742+00:00 heroku[web.1]: State changed from starting to crashed
2016-09-11T15:23:13.640003+00:00 app[web.1]: /app/.meteor/heroku_build/app/programs/server/node_modules/fibers/future.js:280
2016-09-11T15:23:13.640048+00:00 app[web.1]:                        throw(ex);
2016-09-11T15:23:13.640073+00:00 app[web.1]:                        ^
2016-09-11T15:23:13.640075+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-11T15:23:13.640076+00:00 app[web.1]:     at Object.Npm.require (/app/.meteor/heroku_build/app/programs/server/boot.js:198:17)
2016-09-11T15:23:13.640077+00:00 app[web.1]:     at options.fallback (packages/modules-runtime/modules-runtime.js:21:1)
2016-09-11T15:23:13.640078+00:00 app[web.1]:     at meteorInstall.server.main.js (server/main.ts:1:19)
2016-09-11T15:23:13.640079+00:00 app[web.1]:     at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:82:1)
2016-09-11T15:23:13.640079+00:00 app[web.1]:     at server/main.ts:65:4
2016-09-11T15:23:13.723869+00:00 heroku[web.1]: Process exited with status 1

Any Ideas please?

I have run: meteor npm install --save

I have found this in boot.js, but I am not sure what the author was doing.

    try {
      return require(name);
    } catch (e) {
      // Try to guess the package name so we can print a nice
      // error message
      // fileInfo.path is a standard path, use files.pathSep
      var filePathParts = fileInfo.path.split(files.pathSep);
      var packageName = filePathParts[1].replace(/\.js$/, '');

      // XXX better message
      throw new Error(
        "Can't find npm module '" + name +
          "'. Did you forget to call 'Npm.depends' in package.js " +
          "within the '" + packageName + "' package?");
      }

UPDATE

I removed the .gitignore of node_modules/, and I don't get any errors now.

However, I am new to Meteor, so not sure how to test this. But when I try invoke the app with http://remote-thewhozoo.herokuapp.com/ or https://remote-thewhozoo.herokuapp.com/ I get 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

I do check the Mongo Database, and it has got the collections created by my app. So Meteor must be running, I just don't know how to access it.

Any ideas please?

解决方案

Make sure this line:"moment": "^2.14.1" is your package.json then run npm install

这篇关于错误:无法找到npm模块'时刻'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆