我无法做到:
import SimpleSchema from 'simpl-schema';
或使用此命令导入任何其他npm包。我已经通过meteor npm install --save simpl-schema
安装了该软件包。
我还尝试导入其他npm依赖项,如:
import moment from 'moment';
因此,我认为我通常错过了一些重要的东西,以便能够在我的客户端代码中使用NPM包,或者我使用了错误的结构?
我收到错误:
未捕获的SyntaxError:意外的标识符
在浏览器控制台中。
我在运行应用程序之前调用了meteor npm install
。
如果我在服务器端js文件中编写此行import moment from 'moment';
,我会收到以下错误:
应用\服务器\启动\ profilemanagement.js:1 (函数(NPM,资产){(function(){从'moment'导入时刻;
语法错误:意外的令牌导入在C:... meteor \ local \ build \ programs \ server \ boot.js:392:18 at 函数中的Array.forEach()。 .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)在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:...流星\本地\编译\程序\服务器\ boot.js:462:11
我不确定我是否正确安装了babel包。我觉得那里出了点问题。这是我的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"
}
}
似乎是(可能是自上次更新以来?)我对meteor安装及其npm依赖项存在一个主要问题。由于此错误,我无法创建新的流星项目:
错误:错误:无法为测试包安装npm依赖项: 命令失败:C:\ WINDOWS \ system32 \ cmd.exe / c C:\用户\应用程序数据\ Local.meteor \包\流星工具\ 1.6.0._1 \ MT-os.windows.x86_64 \ dev_bundle \ BIN \ npm.cmd 安装npm ERR!代码ENOGIT npm ERR!在$ PATH npm中找不到git二进制文件 呃!错误的ERR!使用git失败了。错误的ERR!请检查你是否有git 安装在你的路径中。
您可以在此处查看此错误: https://github.com/meteor/meteor/issues/8585。它告诉我,由于没有找到Git路径,因此无法安装Npm依赖项。
然而,重新安装Git的解决方案并不适用于我。所以,我认为自上次流星更新以来出现了一些错误。也许唯一的解决方案是完全重新安装流星或使用旧版本?我从我的计算机上用一个较旧的流星版开始了这个项目,卸载并重新安装Babel没有任何区别。
答案 0 :(得分:0)
好的,明白了!虽然我不确切知道产生错误的原因,但我可以通过使用--bare
标志创建一个新的meteor项目来解决问题(现在我知道所有npm依赖项都已正确安装以确保我可以使用{ {1}})并将我的代码复制到项目中。但是,我得到的另一条错误消息告诉我,我的引导程序与我的jquery版本不兼容。在解决此问题之前,我必须删除'import'
文件夹中的codemirror
,这会产生另一个错误
未捕获错误:找不到模块'... / ... / lib / codemirror'
比我安装了client/vendor
以及我在代码中使用的所有必需的数据表npm依赖项,以保持我应用的bootstrap和jquery的兼容性。现在我可以使用jquery@2.2.4
和所有其他导入,不会再出现错误。
最后,一些npm和/或包是错误的,初始错误可以通过创建一个新的流星项目来解决。其他错误与bootstrap / jquery兼容性和codemirror有关。