由IntelliJ卸载的connect-flash,现在无法再次安装

时间:2018-08-30 21:26:09

标签: javascript node.js express npm

我是Node的新手,而我遇到了一个奇怪的问题。 我试图登录使用passportjs时遇到错误,尽管昨天我使用req.flash()进行注册时却报错req.flash(),但它却无法识别module.js:549 throw err; ^ Error: Cannot find module 'connect-flash' at Function.Module._resolveFilename (module.js:547:15) at Function.Module._load (module.js:474:25) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object.<anonymous> (C:\Users\My\Desktop\NodeApp\Test\app.js:8:13) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) 节点模型目录或类似目录。

尝试了多种方法使其工作后,我回想起IntelliJ在我打开i时曾要求我运行npm install命令。因此,我单击了事件日志,并允许IntelliJ运行它,重新启动IntelliJ,然后单击运行并出现错误。

npm install connect-flash

所以我转到node_modules和connect_flash,文件夹在那里,但是上面有一个符号。

在下面的IntelliJ中

enter image description here

在下面的文件浏览器中

enter image description here

当我尝试在文件浏览器中单击它时,出现以下Windows错误

  

C:\ Users \ My \ Desktop \ NodeApp \ Test \ node_modules \ connect-flash不是   可访问文件的名称无法由系统解析

所以我删除了它,并尝试重新安装npm ERR! code ETARGET npm ERR! notarget No matching version found for connect-flash@8 npm ERR! notarget In most cases you or one of your dependencies are requesting npm ERR! notarget a package version that doesn't exist. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\My\AppData\Roaming\npm-cache\_logs\2018-08-30T21_17_28_983Z-debug.log 并返回错误

{{1}}

日志文件产生如下

  

0信息,如果以ok 1 verbise cli ['C:\ Program   Files \ nodejs \ node.exe',1详细cli'C:\ Program   Files \ nodejs \ node_modules \ npm \ bin \ npm-cli.js',1个详细cli
  'install',1冗长的cli'connect-flash'] 2使用npm@5.6.0的信息3   info使用node@v8.11.3 4 verbose npm-session 36d3535b3518b319 5傻   安装loadCurrentTree 6愚蠢安装readLocalPackageData 7 http   获取GET 200 https://registry.npmjs.org/connect-flash 22ms(从   缓存)8愚蠢的注册表:清单没有匹配的版本   缓存中的connect-flash @ 8。强制重新验证9 http获取GET   304 https://registry.npmjs.org/connect-flash 83ms(来自缓存)10   connect-flash @ 8的傻fetchPackageMetaData错误没有匹配项   找到connect-flash @ 8的版本11详细类型范围12详细   堆栈connect-flash:未找到匹配版本的connect-flash @ 8 12   pickManifest上的详细堆栈(C:\ Program   文件\ nodejs \ node_modules \ npm \ node_modules \ pacote \ node_modules \ npm-pick-manifest \ index.js:65:11)   在fetchPackument.then.packument(C:\ Program上的12个详细堆栈   文件\ nodejs \ node_modules \ npm \ node_modules \ pacote \ lib \ fetchers \ registry \ manifest.js:52:18)   tryCatcher上的12个详细堆栈(C:\ Program   文件\ nodejs \ node_modules \ npm \ node_modules \ bluebird \ js \ release \ util.js:16:23)   Promise._settlePromiseFromHandler(C:\ Program中的12个详细堆栈   文件\ nodejs \ node_modules \ npm \ node_modules \ bluebird \ js \ release \ promise.js:512:31)   Promise._settlePromise(C:\ Program中的12个详细堆栈   文件\ nodejs \ node_modules \ npm \ node_modules \ bluebird \ js \ release \ promise.js:569:18)   Promise._settlePromise0(C:\ Program中的12个详细堆栈   文件\ nodejs \ node_modules \ npm \ node_modules \ bluebird \ js \ release \ promise.js:614:10)   Promise._settlePromises(C:\ Program中的12个详细堆栈   文件\ nodejs \ node_modules \ npm \ node_modules \ bluebird \ js \ release \ promise.js:693:18)   Async._drainQueue(C:\ Program上的12个详细堆栈   文件\ nodejs \ node_modules \ npm \ node_modules \ bluebird \ js \ release \ async.js:133:16)   Async._drainQueues(C:\ Program上的12个详细堆栈   文件\ nodejs \ node_modules \ npm \ node_modules \ bluebird \ js \ release \ async.js:143:10)   Instant.Async.drainQueues(C:\ Program上的12个详细堆栈   文件\ nodejs \ node_modules \ npm \ node_modules \ bluebird \ js \ release \ async.js:17:14)   runCallback的12个详细堆栈(timers.js:810:20)12个详细   tryOnImmediate(timers.js:768:5)上的12个详细堆栈   processImmediate [as _immediateCallback](timers.js:745:5)13详细   cwd C:\ Users \ My \ Desktop \ NodeApp \ Test 14详细的Windows_NT 10.0.17134   15详细argv“ C:\ Program Files \ nodejs \ node.exe”“ C:\ Program   Files \ nodejs \ node_modules \ npm \ bin \ npm-cli.js“”安装“   “ connect-flash” 16详细节点v8.11.3 17详细npm v5.6.0 18   错误代码ETARGET 19错误notarget找不到与之匹配的版本   connect-flash @ 8 20错误notarget在大多数情况下,您或您的其中一位   依赖项请求20错误notarget软件包版本   不存在。 21详细出口[1,true]

我以前从未遇到过这样的问题,感谢您的帮助

1 个答案:

答案 0 :(得分:1)

我自己弄清楚了,因为某些原因IntelliJ决定不再需要pacckage.json中的版本号了。在为该版本添加0.1.1之后,我可以为其运行安装命令