(JavaScript的) Ⅳ在從GitHub https://github.com/LearnBoost/socket.io.git錯誤:require.paths被刪除。運行的node.js&socket.io時
運行socket.io示例得到了一個錯誤當我運行 - >節點app.js 它說。 錯誤:require.paths被刪除。改用node_modules文件夾或NODE_PATH環境變量。
有人可以告訴我什麼是錯的? 這個錯誤總是出現在我試過的每個socket.io示例中。
(JavaScript的) Ⅳ在從GitHub https://github.com/LearnBoost/socket.io.git錯誤:require.paths被刪除。運行的node.js&socket.io時
運行socket.io示例得到了一個錯誤當我運行 - >節點app.js 它說。 錯誤:require.paths被刪除。改用node_modules文件夾或NODE_PATH環境變量。
有人可以告訴我什麼是錯的? 這個錯誤總是出現在我試過的每個socket.io示例中。
我在使用cloud foundry sample時遇到此問題。他們告訴你,包括違規行爲:
require.paths.unshift('./node_modules')
這顯然是告訴節點的方式是什麼路徑來搜索模塊爲您require
,在這些情況下,您沒有提供一個明確的路徑。我在某處讀到你傳入的字符串不是以點或斜線開頭的地方。
據我所知,這是使節點0.4應用程序在node_modules目錄中搜索所需的東西。但是在Node 0.6中,你應該使用你的環境和路徑中的設置來進行分類(儘管它在0.6版安裝中對我來說默認工作)。
我遇到了麻煩,因爲雲部署在節點0.4上,我的本地開發設置在節點0.6上。線路在本地發生故障,但將其丟在雲上。我的解決方案是刪除它,並指示雲使用0.6:
vmc push <appname> --runtime=node06
一切似乎在此後工作。 更妙:我發現,你可以編輯你manifest.yml文件來告訴它無需藉助任何命令行開關推過程中自動執行此操作:順便
---
applications:
.:
name: myapp
runtime: node06 # added this line
framework:
name: node
info:
mem: 64M
description: Node.js Application
exec: n
(等)
.. 。如果它一直需要雙重支持的舊版本的需要require.paths以及節點,一個也許可以有條件地運行線根據測試process.version
:
http://nodejs.org/docs/v0.4.9/api/process.html#process.version
可能是你可以試試https://github.com/cloudhead/less.js/issues/320 這是類似於你的問題。
嘗試類似這樣的:
var dust = require('dustjs-helpers');
var compiled = dust.compile("Hello {name}!", "intro");
dust.loadSource(compiled);
dust.render("intro", {
name: "Márcio"
}, function(err, out) {
console.log(out);
});