错误消息:
尝试运行节点服务器时,在找不到模块'neo4j-driver / types / v1'
internal/modules/cjs/loader.js
中生成了。
以下代码是我的neo4j import语句
import Config from "../../../utilities/Config"
const neo4j = require('neo4j-driver').v1;
const driver = neo4j.driver(Config.bolt,
neo4j.auth.basic(Config.neoUsername, Config.neoPassword));
export function createSession() {
return driver.session()
}
export function closeDriver() {
driver.close();
}
我的package.json文件依赖项为:
"devDependencies": {
"babel-core": "^6.23.3",
"babel-loader": "^7.1.5",
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.5",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-react-constant-elements": "^6.23.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.18",
"babel-plugin-transform-regenerator": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"babel-register": "6.26.0",
"babel-runtime": "^6.26.0",
"brotli-gzip-webpack-plugin": "^0.5.0",
"chunk-manifest-webpack-plugin": "^1.1.2",
"clean-webpack-plugin": "^0.1.19",
"css-loader": "^0.28.11",
"cssnano": "^4.1.7",
"cssnano-preset-default": "^4.0.5",
"csv-loader": "^3.0.2",
"express": "^4.16.4",
"file-loader": "^1.1.11",
"html-webpack-plugin": "^3.2.0",
"image-webpack-loader": "^4.4.0",
"npm-run-all": "^4.1.3",
"postcss-cssnext": "3.1.0",
"postcss-loader": "^3.0.0",
"postcss-nested": "^4.1.0",
"progress-bar-webpack-plugin": "^1.11.0",
"react-hot-loader": "^4.3.12",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"uglifyjs-webpack-plugin": "^2.0.1",
"url-loader": "^1.1.2",
"webpack": "^4.20.2",
"webpack-chunk-hash": "^0.6.0",
"webpack-cli": "^3.1.2",
"webpack-dev-middleware": "^3.4.0",
"webpack-hot-middleware": "^2.24.3",
"webpack-merge": "^4.1.4",
"webpack-node-externals": "^1.7.2",
"xml-loader": "^1.2.1"
},
"dependencies": {
"apollo-boost": "^0.1.20",
"apollo-client": "^2.4.5",
"apollo-engine": "^1.1.2",
"apollo-errors": "^1.9.0",
"apollo-server-express": "^1.4.0",
"argon2": "^0.19.3",
"axios": "0.18.0",
"bcrypt-nodejs": "0.0.3",
"body-parser": "^1.18.3",
"boxen": "^2.0.0",
"compression": "^1.7.3",
"connect-mongo": "^2.0.1",
"cookie-parser": "^1.4.3",
"copy-webpack-plugin": "^4.5.3",
"cors": "^2.8.4",
"cross-env": "^5.2.0",
"crypto": "^1.0.1",
"express-graphql": "^0.6.12",
"express-session": "^1.15.6",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"graphql": "^0.13.2",
"graphql-date": "^1.0.3",
"graphql-tag": "^2.10.0",
"graphql-tools": "^2.24.0",
"helmet": "^3.14.0",
"http": "0.0.0",
"https": "^1.0.0",
"isomorphic-fetch": "^2.2.1",
"isomorphic-style-loader": "^4.0.0",
"jsonwebtoken": "^8.3.0",
"mini-css-extract-plugin": "^0.4.4",
"moment": "^2.22.2",
"moment-timezone": "^0.5.21",
"mongoose": "^5.3.2",
"neo4j-driver": "^1.7.1",
"node-fetch": "^2.2.0",
"node-pre-gyp": "^0.11.0",
"node-sass": "^4.9.3",
"node-uuid": "^1.4.8",
"nodemailer": "^4.6.8",
"opn": "^5.4.0",
"optimize-css-assets-webpack-plugin": "^4.0.3",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"path": "^0.12.7",
"prop-types": "^15.6.2",
"qrcode": "^1.3.0",
"react": "^16.7.0-alpha",
"react-apollo": "^2.2.4",
"react-dom": "^16.7.0-alpha",
"react-helmet": "^5.2.0",
"react-intl-universal": "^1.15.0",
"react-router-dom": "^4.3.1",
"recompose": "^0.30.0",
"regenerator-runtime": "^0.11.1",
"semantic-ui-react": "^0.83.0",
"serve-favicon": "^2.5.0",
"speakeasy": "^2.0.0",
"webpack-bundle-analyzer": "^3.0.3",
"webpack-config": "^7.5.0",
"webpack-dev-server": "^3.1.9",
"webpack-manifest-plugin": "^2.0.4",
"whatwg-fetch": "^3.0.0",
"yn": "^2.0.0"
}
文件是使用Webpack 4.20.2构建的 我正在节点v10.13.0上运行,并尝试了11.0.0
我尝试删除node_modules并重新安装。我还尝试了“ neo4j-driver”软件包的1.6.3版,但始终会遇到相同的错误。
该项目通过Bolt协议连接到grapheneDB托管的neo4j数据库。我的实现似乎是neo4j网站上概述的实现。
我是node.js的新手开发人员,但过去曾在我以前的MacBook上运行过此程序。有人有什么想法吗?
答案 0 :(得分:0)
我构建了项目,并在Windows笔记本电脑上运行服务器,并得到了相同的错误。 它使我返回到代码,并深入到错误跟踪中,这一点变得显而易见。 该错误实际上是由与我想像不同的文件引起的。该错误是由于错误地引用了neo4j会话对象。一旦纠正此问题,一切正常。