问题描述:

In my app.js, the line "var cfenv = require 'cfenv';" causes

path.js:8

throw new TypeError('Path must be a string. Received ' +

^

TypeError: Path must be a string. Received undefined

at assertPath (path.js:8:11)

at Object.posix.join (path.js:479:5)

at getPortsFile (/Users/user1/Dev/src/bluemix/dirt/node_modules/ports/index.js:62:15)

at Object.<anonymous> (/Users/user1/Dev/src/bluemix/dirt/node_modules/ports/index.js:13:29)

at Module._compile (module.js:425:26)

at Object.Module._extensions..js (module.js:432:10)

at Module.load (module.js:356:32)

at Function.Module._load (module.js:311:12)

at Module.require (module.js:366:17)

at require (module.js:385:17)

the module 'cfenv' is installed in the local node_modules and the app works on Bluemix.

Here's the package.json, but the versions don't seem to impact it. this only recently started to cause errors, but I cannot trace the origin...

"dependencies": {

"express": "4.12.4",

"cfenv": "1.0.3"

},

"repository": {},

"engines": {

"node": "0.12.x"

}

网友答案:

You have to include your cfenv package, for example using the following code:

var cfenv = require ("cfenv");


From your source I see that you aren't using the correct syntax require('package')

var cfenv = require 'cfenv';

you can see that round brackets are missing.

相关阅读:
Top