Я новичок в том, чтобы обозревать и пытаться выполнить следующие действия: Я создал сервер узлов и попытался получить в браузере пакет под названием openBci.Nodejs Browserify Uncaught TypeError: exists не является функцией
поэтому я следующая структура файла:
Myapp
-...
-public
--app.js
--index.html
--openBCI.js
--...
--javascript
---openBCI
----bundle.js
---...
-node_modules
--openbci
---openBCIBoard.js
--browserify
--...
мой app.js
файл устанавливает сервер для обслуживания папки public
// app.js
var express = require('express');
var app = express();
app.use(express.static('public'));
app.listen(myPort);
я создал следующему openBCI.js
// openBCI.js
var OpenBCIBoard = require('openbci').OpenBCIBoard;
exports.OpenBCIBoard = OpenBCIBoard;
и, наконец, запустил браузер у команды:
$ browserify public/openBCI.js > public/javascript/openBCI/bundle.js
, но когда-то называли в моем index.html
файл, я получил Uncaught TypeError: exists is not a function
в Function.getRoot:
exports.getRoot = function getRoot (file) {
var dir = dirname(file)
, prev
while (true) {
if (dir === '.') {
// Avoids an infinite loop in rare cases, like the REPL
dir = process.cwd()
}
**if (exists(join(dir, 'package.json')) || exists(join(dir, 'node_modules'))) {**
// Found the 'package.json' file or 'node_modules' dir; we're done
return dir
}
if (prev === dir) {
// Got to the top
throw new Error('Could not find module root given file: "' + file
+ '". Do you have a `package.json` file? ')
}
// Try the parent dir next
prev = dir
dir = join(dir, '..')
}
}
Оказывается, что он не может найти оригинальный путь для модуля. Не могли бы вы рассказать мне, что менять? Или, если я вообще понял, как работает браузер? :)