moment2j을 angular2 응용 프로그램으로 가져 오려고합니다. 우선, 나는이 guide을 따라 갔고 나는이 answer을 발견했다. 그러나 제안 된 솔루션을 따라하려고했지만 여전히 moment.js를 가져올 수 없다. 패키지가 있고 실제로 IDE (visual studio)가 문제없이 moment.d.ts 파일을 찾을 수 있지만 npm start로 응용 프로그램을 실행할 때 콘솔에 다음 두 가지 오류가 표시됩니다.moment.js angular2를 가져 오는 방법
"NetworkError: 404 Not Found - http://localhost:3000/node_modules/moment/ " /node_m...moment/ Error: patchProperty/desc.set/[email protected]http://localhost:3000/node_modules/zone.js/dist/zone.js:769:27 Zonehttp://localhost:3000/node_modules/zone.js/dist/zone.js:356:24 Zonehttp://localhost:3000/node_modules/zone.js/dist/zone.js:256:29 ZoneTask/[email protected]http://localhost:3000/node_modules/zone.js/dist/zone.js:423:29
Error loading http://localhost:3000/node_modules/moment as "moment" from 'my file'
나는 여전히
import * as moment from 'moment/moment.d'
아무것도하지만,이 방법
import * as moment from 'moment'
에서이 방법으로 순간을 가져올 수있어 시도 오류가 발생했습니다. 그래서 그것을 제거하고 명령을 다시 입력했다
Typings for "moment" already exist in "node_modules/moment/moment.d.ts". You should let TypeScript resolve the packaged typings and uninstall the copy installed by Typings
잘 나는이 오류를 얻을 : 내 SystemJs'map 속성은 하나
var map = {
'app': 'app', // 'dist',
'@angular': 'node_modules/@angular',
'services': 'app/service',
'moment': 'node_modules/moment',//moment.js
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
'rxjs': 'node_modules/rxjs'
};
나는이 오류가 typings에 설치하려고하면 이것이다
typings ERR! message Unable to find "moment" ("npm") in the registry.
그래서이 딜레마에서 벗어나는 방법은 무엇입니까?
[2 각 타입 스크립트에서 moment.js 라이브러리 사용 방법] (http://stackoverflow.com/questions/35166168/how-to-use-moment-js-library-in-angular-2 -typeescript-app) –
이 답변에는 systemjs config에 대한 설명도 있습니다. 그리고 문제는 그것을 어떻게 사용하는 것이 아니라 그것을 어떻게 가져올 것인가입니다. – mautrok