2015-11-25 161 views
1

安裝最新的角度來使用角度未定義,參考錯誤?

npm install [email protected] 

接下來我的項目,我添加了這個匿名函數來我app.js

(function() { 
    angular.module('TimeWaste', []); 
}()); 

而且我在我的server.js使用此以參考我的node_modules

app.use('/node_modules', express.static(__dirname + "/node_modules")); 

然後我用添加引用到我的項目:

<script scr="node_modules/angular/angular.js"> 
</script> 

我收到錯誤的app.js文件,它表明角沒有定義。

Uncaught ReferenceError: angular is not defined(anonymous function) @ app.js:2(anonymous function) @ app.js:3

有些幫助嗎?

+0

你好嗎angular.js 404?你可以發佈你的app.js嗎?你有沒有試過我的答案?你的索引文件在哪個文件夾中? – Rodmentou

+0

我已經在我的帖子中發佈了我的app.js。是。試過你的答案,我沒有解決我的問題。一些其他的建議如何得到這個固定的? – n00bie

+0

在哪個文件夾中您的索引文件與

0
app.use('/node_modules', express.static(__dirname + "/node_modules")); 

這將使node_modules公用文件夾。

所以,你只需要使用

<script scr="angular/angular.js"> 
</script> 

導入角。 ;)

+0

當我把Angular CDN作爲參考時,它可以工作。任何想到爲什麼要安裝軟件包並引用它,它不起作用? – n00bie