我尝试将AngularJS 1.6.5
导入我的应用。
我使用webpack 3.7.1
作为模块捆绑器。
另外,我使用typescript
来传输我的代码。
的package.json:
{
"name": "webpack_test_app",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"ts-loader": "^2.3.7",
"webpack": "^3.7.1"
},
"dependencies": {
"angular-ui-bootstrap": "^2.5.0",
"angular": "1.6.5"
}
}
webpack.config.js:
module.exports = {
entry: './app.js',
output: {
filename: './views/resources/js/bundle.js'
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
}
};
app.ts
import angular from './node_modules/angular/angular.js';
console.log('angular is -> ', angular);
完成所有chrome控制台打印angular is -> undefined
我也尝试了import angular from './node_modules/angular/angular';
答案 0 :(得分:1)
安装打字
要做 Step1:执行命令安装tsd
npm install -g tsd
步骤3:执行命令以安装打字
tsd install angular
tsd install angular-route
然后在app.ts
import angular from 'angular';
答案 1 :(得分:0)
我试图包含所有依赖项。
import * as angular from 'angular';