npm install 后 Node 找不到依赖项

All*_*ang 4 node.js npm digital-ocean ghost

我是 Node.js 新手,在我的 DigitalOcean VPS 上遇到了这个问题,我的 Web 应用程序 (Ghost) 抱怨即使在安装后也找不到特定模块:

\n\n
root@3fen:/var/www/ghost# sudo npm install -g ghost-gql\nghost-gql@0.0.2 /usr/local/lib/node_modules/ghost-gql\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 lodash@3.10.1\n\nroot@3fen:/var/www/ghost# node index.js\nERROR: Ghost is unable to start due to missing dependencies:\n  Cannot find module 'ghost-gql'\n  Cannot find module 'jsonpath'\n\nPlease run `npm install --production` and try starting Ghost again.\nHelp and documentation can be found at http://support.ghost.org.\n
Run Code Online (Sandbox Code Playgroud)\n\n

我确认这两个条目都存在于package.json的依赖项块中,并且我也尝试过npm install --production,它以静默方式执行,但仍然出现相同的错误。

\n\n

如果我在上述步骤中遗漏了任何内容,请指出我。谢谢你!

\n

pra*_*sun 5

看起来环境变量 NODE_PATH 中没有设置全局 npm 路径。

npm config get prefix这需要是与连接的路径node_modules

在你的情况下

export NODE_PATH=/usr/local/node_modules
Run Code Online (Sandbox Code Playgroud)