Javascript 错误:找不到模块“../lib/cli”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29323982/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 03:12:03  来源:igfitidea点击:

Error: Cannot find module '../lib/cli'

javascriptnpm

提问by Noah Clark

I'm completely new to javascript development and I'm getting the following error as I work my way through the backbone_blueprints book. Here is the error I get:

我对 javascript 开发完全陌生,当我通过backbone_blueprints 书工作时遇到以下错误。这是我得到的错误:

> [email protected] start /Users/noahc/Projects/backbone_blueprints/blog
> nodemon server.js


module.js:340
    throw err;
          ^
Error: Cannot find module '../lib/cli'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/Users/noahc/Projects/backbone_blueprints/blog/node_modules/.bin/nodemon:3:11)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

npm ERR! Darwin 14.1.0
npm ERR! argv "node" "/usr/local/bin/npm" "start"
npm ERR! node v0.10.33
npm ERR! npm  v2.1.11
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `nodemon server.js`
npm ERR! Exit status 8
npm ERR! 
npm ERR! Failed at the [email protected] start script 'nodemon server.js'.
npm ERR! This is most likely a problem with the simple-blog package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     nodemon server.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls simple-blog
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/noahc/Projects/backbone_blueprints/blog/npm-debug.log
? ~/Projects/backbone_blueprints/blog npm install                                                                   ruby-2.1.3
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data

Here is the debug log:

这是调试日志:

0 info it worked if it ends with ok 
1 verbose cli [ 'node', '/usr/local/bin/npm', 'install' ]
2 info using [email protected]
3 info using [email protected]
4 verbose node symlink /usr/local/bin/node
5 error install Couldn't read dependencies
6 verbose stack Error: ENOENT, open '/Users/noahc/Projects/backbone_blueprints/package.json'
7 verbose cwd /Users/noahc/Projects/backbone_blueprints
8 error Darwin 14.1.0
9 error argv "node" "/usr/local/bin/npm" "install"
10 error node v0.10.33
11 error npm  v2.1.11
12 error path /Users/noahc/Projects/backbone_blueprints/package.json
13 error code ENOPACKAGEJSON
14 error errno 34 
15 error package.json ENOENT, open '/Users/noahc/Projects/backbone_blueprints/package.json'
15 error package.json This is most likely not a problem with npm itself.
15 error package.json npm can't find a package.json file in your current directory.
16 verbose exit [ 34, true ]

And this:

和这个:

? ~/Projects/backbone_blueprints/blog which node                                                                    ruby-2.1.3
/usr/local/bin/node
? ~/Projects/backbone_blueprints/blog which npm                                                                     ruby-2.1.3
/usr/local/bin/npm

I thought it might be a path issue and so I added export NODE_PATH=/opt/lib/node_modulesto my .zshrc file and sourced it and that seemed to have no impact.

我认为这可能是一个路径问题,所以我添加export NODE_PATH=/opt/lib/node_modules到我的 .zshrc 文件中并获取它,这似乎没有影响。

Any thoughts on anyway I can troubleshoot this or try to better understand what is actually happening?

无论如何我可以解决这个问题或尝试更好地了解实际发生的事情的任何想法?

采纳答案by Noah Clark

I found the fix. I had to install nodemon globally doing this: npm install nodemon -g

我找到了解决办法。我必须在全局安装 nodemon 这样做:npm install nodemon -g

回答by Googol

My solution was to just delete the directory /node_modules/ and to make a fresh install afterwards with npm install.

我的解决方案是删除目录 /node_modules/ 并在之后使用npm install.

回答by superluminary

Nodedemon is looking for its ../lib/clifolder in its own directory and not finding it. You probably have a messed up install. This can happen sometimes when you use finder to copy a project from one folder to another.

Nodedemon 正在../lib/cli自己的目录中寻找它的文件夹,但没有找到。你可能有一个混乱的安装。当您使用 finder 将项目从一个文件夹复制到另一个文件夹时,有时会发生这种情况。

If you blow away your node_modules directory and reinstall from scratch, you should restore the folder.

如果您删除了 node_modules 目录并从头开始重新安装,则应该恢复该文件夹。

cd your_project_folder
rm -rf node_modules
npm install

Edit:

编辑:

You might also use yarn.

您也可以使用纱线。

cd your_project_folder
rm -rf node_modules
yarn

回答by Chad Scira

You can try doing the following

您可以尝试执行以下操作

npm uninstall nodemon
npm install nodemon

回答by user3444999

Protractor have changed the location.The lib/built protractor files now reside in the built directory of the package. You should just be able to direct your IDE to built/cli.js This worked for me.

量角器已更改位置。lib/built 量角器文件现在位于包的构建目录中。您应该能够将您的 IDE 定向到 built/cli.js 这对我有用。

Check their Github Issue link :

检查他们的 Github 问题链接:

https://github.com/angular/protractor/issues/3089

https://github.com/angular/protractor/issues/3089

回答by guy mograbi

Had the same problem.

有同样的问题。

I use protractor --elementExplorerand it works for me

我使用protractor --elementExplorer它对我有用