流星 - 无法使用/进口NPM包

我不能做:流星 - 无法使用/进口NPM包

import SimpleSchema from 'simpl-schema'; 

或导入任何其他NPM包使用此命令。我已经通过meteor npm install --save simpl-schema安装了该软件包。

我也试图引入其他NPM的依赖关系,如:

import moment from 'moment'; 

因此,我认为,我通常错过了一些重要的是能够为需要NPM包在我的客户端代码或我使用错误的结构?

我得到的错误:

Uncaught SyntaxError: Unexpected identifier

在浏览器控制台。 我将不胜感激任何帮助,谢谢!

编辑:

我已经在运行应用程序之前调用meteor npm install

如果我的代码在服务器端的js文件这一行import moment from 'moment';,我得到以下错误:

app\server\startup\profilemanagement.js:1 (function(NPM,Assets){(function(){import moment from 'moment';

SyntaxError: Unexpected token import at C:...meteor\local\build\programs\server\boot.js:392:18 at Array.forEach() at Function..each..forEach (C:...meteor\packages\meteor-tool\1.6.0:1\mt-os.windows.x86_64\dev_bundle\server-lib\node_modules\underscore\underscore.js:79:11) at C:...meteor\local\build\programs\server\boot.js:220:5 at C:...meteor\local\build\programs\server\boot.js:463:5 at Function.run (C:...meteor\local\build\programs\server\profile.js:510:12) at C:...meteor\local\build\programs\server\boot.js:462:11

我不知道我是否安装了巴贝尔包correcty。我认为那里出了问题。这是我的package.json:

{ 

"dependencies": {

"abbrev": "^1.1.0",

"addressparser": "^1.0.1",

"ajv": "^5.2.2",

"ansi-regex": "^3.0.0",

"aproba": "^1.2.0",

"are-we-there-yet": "^1.1.4",

"asn1": "^0.2.3",

"assert-plus": "^1.0.0",

"asynckit": "^0.4.0",

"aws-sign2": "^0.7.0",

"aws4": "^1.6.0",

"babel-runtime": "^6.26.0",

"balanced-match": "^1.0.0",

"bcrypt": "^1.0.3",

"bcrypt-pbkdf": "^1.0.1",

"block-stream": "0.0.9",

"boom": "^5.2.0",

"brace-expansion": "^1.1.8",

"buildmail": "^4.0.1",

"caseless": "^0.12.0",

"chart.js": "^2.7.0",

"chartjs-color": "^2.2.0",

"cloudinary": "^1.9.0",

"co": "^4.6.0",

"code-point-at": "^1.1.0",

"color-convert": "^1.9.0",

"color-name": "^1.1.3",

"combined-stream": "^1.0.5",

"concat-map": "0.0.1",

"console-control-strings": "^1.1.0",

"core-js": "^2.5.1",

"core-util-is": "^1.0.2",

"cryptiles": "^3.1.2",

"dashdash": "^1.14.1",

"debug": "^3.0.1",

"deep-extend": "^0.5.0",

"delayed-stream": "^1.0.0",

"delegates": "^1.0.0",

"ecc-jsbn": "^0.1.1",

"extend": "^3.0.1",

"extsprintf": "^1.3.0",

"fast-deep-equal": "^1.0.0",

"fontawesome": "^4.7.2",

"forever-agent": "^0.6.1",

"form-data": "^2.3.1",

"fs.realpath": "^1.0.0",

"fstream": "^1.0.11",

"fstream-ignore": "^1.0.5",

"gauge": "^2.7.4",

"getpass": "^0.1.7",

"glob": "^7.1.2",

"graceful-fs": "^4.1.11",

"har-schema": "^2.0.0",

"har-validator": "^5.0.3",

"has-unicode": "^2.0.1",

"hawk": "^6.0.2",

"hoek": "^4.2.0",

"http-signature": "^1.2.0",

"iconv-lite": "^0.4.19",

"inflight": "^1.0.6",

"inherits": "^2.0.3",

"ini": "^1.3.4",

"is-fullwidth-code-point": "^2.0.0",

"is-typedarray": "^1.0.0",

"isarray": "^2.0.2",

"isstream": "^0.1.2",

"jasny-bootstrap": "^3.1.3",

"jodid25519": "^1.0.2",

"jsbn": "^1.1.0",

"json-schema": "^0.2.3",

"json-schema-traverse": "^0.3.1",

"json-stable-stringify": "^1.0.1",

"json-stringify-safe": "^5.0.1",

"jsonify": "0.0.0",

"jsprim": "^1.4.1",

"libbase64": "^0.2.0",

"libmime": "^3.1.0",

"libqp": "^1.1.0",

"lodash": "^4.17.4",

"mailcomposer": "^4.0.2",

"meteor-node-stubs": "^0.2.11",

"mime-db": "^1.30.0",

"mime-types": "^2.1.17",

"minimatch": "^3.0.4",

"minimist": "^1.2.0",

"mkdirp": "^0.5.1",

"moment": "^2.18.1",

"ms": "^2.0.0",

"nan": "^2.7.0",

"node-pre-gyp": "^0.6.37",

"nodemailer": "^4.1.0",

"nodemailer-fetch": "^2.1.0",

"nodemailer-shared": "^2.0.0",

"nopt": "^4.0.1",

"npmlog": "^4.1.2",

"number-is-nan": "^1.0.1",

"oauth-sign": "^0.8.2",

"object-assign": "^4.1.1",

"object-inspect": "^1.3.0",

"object-keys": "^1.0.11",

"once": "^1.4.0",

"os-homedir": "^1.0.2",

"os-tmpdir": "^1.0.2",

"osenv": "^0.1.4",

"path-is-absolute": "^1.0.1",

"path-parse": "^1.0.5",

"performance-now": "^2.1.0",

"process-nextick-args": "^1.0.7",

"punycode": "^2.1.0",

"q": "^1.5.0",

"qs": "^6.5.1",

"rc": "^1.2.1",

"readable-stream": "^2.3.3",

"regenerator-runtime": "^0.11.0",

"request": "^2.82.0",

"resolve": "^1.4.0",

"resumer": "0.0.0",

"rimraf": "^2.6.2",

"safe-buffer": "^5.1.1",

"semver": "^5.4.1",

"set-blocking": "^2.0.0",

"signal-exit": "^3.0.2",

"sntp": "^2.0.2",

"sshpk": "^1.13.1",

"string-width": "^2.1.1",

"string.prototype.trim": "^1.1.2",

"string_decoder": "^1.0.3",

"stringstream": "0.0.5",

"strip-ansi": "^4.0.0",

"strip-json-comments": "^2.0.1",

"sweetalert": "^1.1.3",

"tape": "^4.8.0",

"tar": "^4.0.1",

"tar-pack": "^3.4.0",

"through": "^2.3.8",

"tough-cookie": "^2.3.2",

"tunnel-agent": "^0.6.0",

"tweetnacl": "^1.0.0",

"uid-number": "0.0.6",

"util-deprecate": "^1.0.2",

"uuid": "^3.1.0",

"verror": "^1.10.0",

"wide-align": "^1.1.2",

"wow.js": "^1.2.2",

"wrappy": "^1.0.2",

"yallist": "^3.0.2"

}

}

第二个编辑:(?也许自上次更新)

好吧,这似乎是我有流星安装和新公共管理的重大课题依赖。我不能够创建一个新的流星项目因这个错误:

Error: Error: Could not install npm dependencies for test-packages: Command failed: C:\WINDOWS\system32\cmd.exe /c C:\Users...\AppData\Local.meteor\packages\meteor-tool\1.6.0._1\mt-os.windows.x86_64\dev_bundle\bin\npm.cmd install npm ERR! code ENOGIT npm ERR! No git binary found in $PATH npm ERR! npm ERR! Failed using git. npm ERR! Please check if you have git installed and in your PATH.

你可以在这里检查这个错误: https://github.com/meteor/meteor/issues/8585。它告诉我,由于没有找到Git路径,所以不能安装Npm依赖项。

但是,重新安装Git的解决方案并不适合我。所以,我认为自上次流星更新以来,一般情况都是错误的......我现在有点卡住了。也许唯一的解决办法是重新安装流星或使用旧版本?我从我的电脑开始使用旧流星版本的这个项目,卸载并重新安装babel没有任何区别。

回答:

好的,明白了!尽管我不清楚导致错误的原因,但我可以通过创建一个带有--bare标志的新流星项目来解决这个问题(所以现在我知道所有的npm依赖项都已正确安装,以确保我可以使用'import')并复制了我的代码到项目中。然而,比我得到另一个错误消息,告诉我,我的引导程序与我的jQuery版本不兼容。解决此之前,我曾在我的client/vendor文件夹,这会产生另一个错误

Uncaught Error: Cannot find module ‘…/…/lib/codemirror’

比我安装删除codemirror[email protected]再加上我在我的代码使用所有必要的数据表NPM的依赖,以保持我的应用引导和jQuery的兼容性。现在我可以使用import SimpleSchema from 'simpl-schema'和所有其他导入,并且不会再出现错误。

最后,一些npm和/或包是错误的,最初的错误可以通过创建一个新的流星项目来解决。其他错误与bootstrap/jquery兼容性和codemirror相关。

以上是 流星 - 无法使用/进口NPM包 的全部内容, 来源链接: utcz.com/qa/266412.html

回到顶部