npmでいくつかのパッケージをインストールしようとしています。例:Angular2:npmインストール後にパッケージを見つけることができません
npm install ng2-storage
パッケージはnode_modulesディレクトリに正しくインストールされています。
私は経由してライブラリをインポートしよう:
import { StorageSettings } from 'ng2-storage';
しかし、私はこのエラーを取得する起動NPM起動したとき:
app/main.ts(3,33): error TS2307: Cannot find module 'ng2-storage'.
私はすべてのサードパーティ製のパッケージでこの問題を抱えています。
アップデート:私のシステム設定にそれを追加しました:
/**
* System configuration for Angular 2 samples
* Adjust as necessary for your application needs.
*/
(function(global) {
// map tells the System loader where to look for things
var map = {
'app': 'dist', // 'dist',
'@angular': 'node_modules/@angular',
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
'rxjs': 'node_modules/rxjs',
'ng2-storage': 'node_modules/ng2-storage'
};
// packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app': { main: 'main.js', defaultExtension: 'js' },
'rxjs': { defaultExtension: 'js' },
'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
'ng2-storage': { main: 'index.js', defaultExtension: 'js' },
};
var ngPackageNames = [
'common',
'compiler',
'core',
'forms',
'http',
'platform-browser',
'platform-browser-dynamic',
'router',
'router-deprecated',
'upgrade',
];
// Individual files (~300 requests):
function packIndex(pkgName) {
packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' };
}
// Bundled (~40 requests):
function packUmd(pkgName) {
packages['@angular/'+pkgName] = { main: 'bundles/' + pkgName + '.umd.js', defaultExtension: 'js' };
}
// Most environments should use UMD; some (Karma) need the individual index files
var setPackageConfig = System.packageWithIndex ? packIndex : packUmd;
// Add package entries for angular packages
ngPackageNames.forEach(setPackageConfig);
var config = {
map: map,
packages: packages
};
System.config(config);
})(this);
main.ts
import { StorageSettings } from 'ng2-storage';
同じ問題...
ダウンロードしたパッケージをインデックスページに含めましたか? –
いいえ、私はそれが必要ではないと思います。イオンアプリを開発するときに手動で含める必要はありません。 – rakete
またはローダーにありますか? –