简体   繁体   English

找不到模块“风帆”

[英]Cannot find module 'sails'

I am trying to run a sails application with Webstorm 7.0.3. 我正在尝试使用Webstorm 7.0.3运行Sails应用程序。 this appear when i try to run the server in the console log: 当我尝试在控制台日志中运行服务器时出现:


module.js:340 throw err; module.js:340 throw err; ^ Error: Cannot find module 'sails' 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. ^错误:在Module.require(module.js:364 :)的Function.Module._load(module.js:280:25)的Function.Module._resolveFilename(module.js:338:15)上找不到模块'sails' 17)在对象的require(module.js:380:17)。 (C:\\Users** \\projects\\WebstormProjects** \\app.js:2:1) 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 Module.runMain [as _onTimeout] (module.js:497:10) (C:\\ Users ** \\ projects \\ WebstormProjects ** \\ app.js:2:1)位于Object.Module._extensions..js(module.js:474)的Module._compile(module.js:456:26) :10)在Module.load(module.js:356:32)在Function.Module._load(module.js:312:12)在Module.runMain [as _onTimeout](module.js:497:10)

Process finished with exit code 8 流程结束,退出代码为8


i installed sails globaly. 我安装帆全球。 i know that this is dont work because it cant find the sails module in the project's local 'node_modules' directory. 我知道这是行不通的,因为它无法在项目的本地“ node_modules”目录中找到sails模块。 if ill install again 'sails' localy it will work. 如果再次安装不正确的“ sails”语言,它将正常工作。 but i dont want to... 但我不想...

Is there a way to make it work with sails global install? 有没有办法使它与Sails全局安装一起使用? thanks! 谢谢!

The sails module that your code is looking for is not the same thing as the sails command you're executing at the terminal. 您的代码正在寻找的sails模块与您在终端上执行的sails命令不同。

The command generates project skeletons. 该命令生成项目框架。 The module is the code that actually makes it run. 该模块是实际使它运行的代码。

You need to install the command globally and the module locally. 您需要全局安装命令,并在本地安装模块。

Global installation (using npm install -g ) does not make modules available globally to all node applications, it's only there for command line stuff. 全球安装(使用npm install -g不会使全球范围内提供给所有节点的应用模块,它只是存在于命令行的东西。

If your applications relies on Sails, you should have it in your dependencies in package.json as well as installed locally. 如果您的应用程序依赖于Sails,则应将其放在package.json中的依赖项中,以及在本地安装。

If you don't like the way that npm creates a copy of each module locally, use yarn and tell it to symlink the cached version. 如果您不喜欢npm在本地创建每个模块的副本的方式,请使用yarn并告诉它符号链接缓存的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM