2016-07-01 164 views
1

當「快車stormpath」當我嘗試運行node server.js(在普通的終端沒有被超級用戶或root)我得到這個錯誤:找不到模塊啓動服務器

[email protected]:~/my-webapp$ node server.js 
module.js:442 
    throw err; 
    ^

Error: Cannot find module 'express-stormpath' 
    at Function.Module._resolveFilename (module.js:440:15) 
    at Function.Module._load (module.js:388:25) 
    at Module.require (module.js:468:17) 
    at require (internal/module.js:20:19) 
    at Object.<anonymous> (/home/alphaunlimitedg/my-webapp/server.js:2:17) 
    at Module._compile (module.js:541:32) 
    at Object.Module._extensions..js (module.js:550:10) 
    at Module.load (module.js:458:32) 
    at tryModuleLoad (module.js:417:12) 
    at Function.Module._load (module.js:409:3) 
[email protected]:~/my-webapp$ 

我已經安裝了快遞包裹在根,超級用戶和normaluser與命令:npm install express

它的工作,沒有給任何錯誤!但它仍然顯示上面的錯誤。任何想法如何解決這個問題?

PS:這是我已經按照以下步驟操作:

[email protected]:~$ npm install express 
/home/alphaunlimitedg 
└─┬ [email protected] 
    ├─┬ [email protected] 
    │ ├─┬ [email protected] 
    │ │ └── [email protected] 
    │ └── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├─┬ [email protected] 
    │ └── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├─┬ [email protected] 
    │ ├── [email protected] 
    │ └── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├─┬ [email protected] 
    │ └── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├─┬ [email protected] 
    │ ├── [email protected] 
    │ └── [email protected] 
    ├── [email protected] 
    ├── [email protected] 
    ├─┬ [email protected] 
    │ ├── [email protected] 
    │ ├─┬ [email protected] 
    │ │ ├── [email protected] 
    │ │ └── [email protected] 
    │ └── [email protected] 
    ├── [email protected] 
    ├─┬ [email protected] 
    │ └── [email protected] 
    ├── [email protected] 
    └── [email protected] 

npm WARN enoent ENOENT: no such file or directory, open '/home/alphaunlimitedg/package.json' 
npm WARN alphaunlimitedg No description 
npm WARN alphaunlimitedg No repository field. 
npm WARN alphaunlimitedg No README data 
npm WARN alphaunlimitedg No license field. 
[email protected]:~$ express --help 
The program 'express' is currently not installed. You can install it by typing: 
sudo apt install node-express-generator 
[email protected]:~$ sudo apt install node-express-generator 
[sudo] password for alphaunlimitedg: 
Reading package lists... Done 
Building dependency tree  
Reading state information... Done 
The following packages were automatically installed and are no longer required: 
    gyp javascript-common libjs-inherits libjs-jquery libjs-node-uuid 
    libjs-underscore libssl-dev libssl-doc libuv1 libuv1-dev zlib1g-dev 
Use 'sudo apt autoremove' to remove them. 
The following additional packages will be installed: 
    node-accepts node-buffer-crc32 node-commander node-cookie 
    node-cookie-signature node-crc node-debug node-depd node-escape-html 
    node-etag node-express node-fresh node-media-typer node-merge-descriptors 
    node-methods node-mime node-mime-types node-mkdirp node-negotiator 
    node-on-finished node-parseurl node-path-to-regexp node-qs node-range-parser 
    node-send node-serve-static node-type-is node-utils-merge 
The following NEW packages will be installed: 
    node-accepts node-buffer-crc32 node-commander node-cookie 
    node-cookie-signature node-crc node-debug node-depd node-escape-html 
    node-etag node-express node-express-generator node-fresh node-media-typer 
    node-merge-descriptors node-methods node-mime node-mime-types node-mkdirp 
    node-negotiator node-on-finished node-parseurl node-path-to-regexp node-qs 
    node-range-parser node-send node-serve-static node-type-is node-utils-merge 
0 upgraded, 29 newly installed, 0 to remove and 11 not upgraded. 
Need to get 203 kB/227 kB of archives. 
After this operation, 1999 kB of additional disk space will be used. 
Do you want to continue? [Y/n] y 
Get:1 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-negotiator all 0.4.8-1 [6980 B] 
Get:2 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-mime-types all 2.0.2-2 [17,4 kB] 
Get:3 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-accepts all 1.1.1-1 [5314 B] 
Get:4 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-buffer-crc32 all 0.2.1-1 [4876 B] 
Get:5 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-commander all 2.4.0-1 [13,2 kB] 
Get:6 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-cookie all 0.1.2-2 [3692 B] 
Get:7 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-cookie-signature all 1.0.3-1 [3320 B] 
Get:8 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-crc all 3.0.0-3 [8378 B] 
Get:9 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-debug all 2.1.0+dfsg-2 [12,3 kB] 
Get:10 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-depd all 1.0.0-1 [9982 B] 
Get:11 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-escape-html all 1.0.1-1 [3016 B] 
Get:12 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-etag all 1.4.0-1 [4692 B] 
Get:13 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-parseurl all 1.3.0-1 [4544 B] 
Get:14 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-methods all 1.1.0-1 [3104 B] 
Get:15 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-media-typer all 0.3.0-1 [5408 B] 
Get:16 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-type-is all 1.5.2-1 [5502 B] 
Get:17 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-fresh all 0.2.0-1 [3226 B] 
Get:18 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-on-finished all 2.1.0-2 [5668 B] 
Get:19 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-range-parser all 0.0.4+git7d1cd72a-1 [3286 B] 
Get:20 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-send all 0.9.4-1 [10,8 kB] 
Get:21 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-merge-descriptors all 0.0.2-1 [3226 B] 
Get:22 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-path-to-regexp all 1.0.1-1 [6512 B] 
Get:23 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-utils-merge all 1.0.0-1 [3362 B] 
Get:24 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-serve-static all 1.6.4-2 [6160 B] 
Get:25 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-express all 4.1.1~dfsg-1 [41,5 kB] 
Get:26 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 node-express-generator all 4.0.0-2 [7478 B] 
Fetched 203 kB in 0s (558 kB/s)     
Selecting previously unselected package node-negotiator. 
(Reading database ... 215457 files and directories currently installed.) 
Preparing to unpack .../node-negotiator_0.4.8-1_all.deb ... 
Unpacking node-negotiator (0.4.8-1) ... 
Selecting previously unselected package node-mime-types. 
Preparing to unpack .../node-mime-types_2.0.2-2_all.deb ... 
Unpacking node-mime-types (2.0.2-2) ... 
Selecting previously unselected package node-accepts. 
Preparing to unpack .../node-accepts_1.1.1-1_all.deb ... 
Unpacking node-accepts (1.1.1-1) ... 
Selecting previously unselected package node-buffer-crc32. 
Preparing to unpack .../node-buffer-crc32_0.2.1-1_all.deb ... 
Unpacking node-buffer-crc32 (0.2.1-1) ... 
Selecting previously unselected package node-commander. 
Preparing to unpack .../node-commander_2.4.0-1_all.deb ... 
Unpacking node-commander (2.4.0-1) ... 
Selecting previously unselected package node-cookie. 
Preparing to unpack .../node-cookie_0.1.2-2_all.deb ... 
Unpacking node-cookie (0.1.2-2) ... 
Selecting previously unselected package node-cookie-signature. 
Preparing to unpack .../node-cookie-signature_1.0.3-1_all.deb ... 
Unpacking node-cookie-signature (1.0.3-1) ... 
Selecting previously unselected package node-crc. 
Preparing to unpack .../node-crc_3.0.0-3_all.deb ... 
Unpacking node-crc (3.0.0-3) ... 
Selecting previously unselected package node-debug. 
Preparing to unpack .../node-debug_2.1.0+dfsg-2_all.deb ... 
Unpacking node-debug (2.1.0+dfsg-2) ... 
Selecting previously unselected package node-depd. 
Preparing to unpack .../node-depd_1.0.0-1_all.deb ... 
Unpacking node-depd (1.0.0-1) ... 
Selecting previously unselected package node-escape-html. 
Preparing to unpack .../node-escape-html_1.0.1-1_all.deb ... 
Unpacking node-escape-html (1.0.1-1) ... 
Selecting previously unselected package node-etag. 
Preparing to unpack .../node-etag_1.4.0-1_all.deb ... 
Unpacking node-etag (1.4.0-1) ... 
Selecting previously unselected package node-parseurl. 
Preparing to unpack .../node-parseurl_1.3.0-1_all.deb ... 
Unpacking node-parseurl (1.3.0-1) ... 
Selecting previously unselected package node-qs. 
Preparing to unpack .../node-qs_2.2.4-1_all.deb ... 
Unpacking node-qs (2.2.4-1) ... 
Selecting previously unselected package node-methods. 
Preparing to unpack .../node-methods_1.1.0-1_all.deb ... 
Unpacking node-methods (1.1.0-1) ... 
Selecting previously unselected package node-media-typer. 
Preparing to unpack .../node-media-typer_0.3.0-1_all.deb ... 
Unpacking node-media-typer (0.3.0-1) ... 
Selecting previously unselected package node-type-is. 
Preparing to unpack .../node-type-is_1.5.2-1_all.deb ... 
Unpacking node-type-is (1.5.2-1) ... 
Selecting previously unselected package node-fresh. 
Preparing to unpack .../node-fresh_0.2.0-1_all.deb ... 
Unpacking node-fresh (0.2.0-1) ... 
Selecting previously unselected package node-mime. 
Preparing to unpack .../node-mime_1.3.4-1_all.deb ... 
Unpacking node-mime (1.3.4-1) ... 
Selecting previously unselected package node-on-finished. 
Preparing to unpack .../node-on-finished_2.1.0-2_all.deb ... 
Unpacking node-on-finished (2.1.0-2) ... 
Selecting previously unselected package node-range-parser. 
Preparing to unpack .../node-range-parser_0.0.4+git7d1cd72a-1_all.deb ... 
Unpacking node-range-parser (0.0.4+git7d1cd72a-1) ... 
Selecting previously unselected package node-send. 
Preparing to unpack .../node-send_0.9.4-1_all.deb ... 
Unpacking node-send (0.9.4-1) ... 
Selecting previously unselected package node-merge-descriptors. 
Preparing to unpack .../node-merge-descriptors_0.0.2-1_all.deb ... 
Unpacking node-merge-descriptors (0.0.2-1) ... 
Selecting previously unselected package node-path-to-regexp. 
Preparing to unpack .../node-path-to-regexp_1.0.1-1_all.deb ... 
Unpacking node-path-to-regexp (1.0.1-1) ... 
Selecting previously unselected package node-utils-merge. 
Preparing to unpack .../node-utils-merge_1.0.0-1_all.deb ... 
Unpacking node-utils-merge (1.0.0-1) ... 
Selecting previously unselected package node-serve-static. 
Preparing to unpack .../node-serve-static_1.6.4-2_all.deb ... 
Unpacking node-serve-static (1.6.4-2) ... 
Selecting previously unselected package node-express. 
Preparing to unpack .../node-express_4.1.1~dfsg-1_all.deb ... 
Unpacking node-express (4.1.1~dfsg-1) ... 
Selecting previously unselected package node-mkdirp. 
Preparing to unpack .../node-mkdirp_0.5.0-1_all.deb ... 
Unpacking node-mkdirp (0.5.0-1) ... 
Selecting previously unselected package node-express-generator. 
Preparing to unpack .../node-express-generator_4.0.0-2_all.deb ... 
Unpacking node-express-generator (4.0.0-2) ... 
Processing triggers for man-db (2.7.5-1) ... 
Setting up node-negotiator (0.4.8-1) ... 
Setting up node-mime-types (2.0.2-2) ... 
Setting up node-accepts (1.1.1-1) ... 
Setting up node-buffer-crc32 (0.2.1-1) ... 
Setting up node-commander (2.4.0-1) ... 
Setting up node-cookie (0.1.2-2) ... 
Setting up node-cookie-signature (1.0.3-1) ... 
Setting up node-crc (3.0.0-3) ... 
Setting up node-debug (2.1.0+dfsg-2) ... 
Setting up node-depd (1.0.0-1) ... 
Setting up node-escape-html (1.0.1-1) ... 
Setting up node-etag (1.4.0-1) ... 
Setting up node-parseurl (1.3.0-1) ... 
Setting up node-qs (2.2.4-1) ... 
Setting up node-methods (1.1.0-1) ... 
Setting up node-media-typer (0.3.0-1) ... 
Setting up node-type-is (1.5.2-1) ... 
Setting up node-fresh (0.2.0-1) ... 
Setting up node-mime (1.3.4-1) ... 
Setting up node-on-finished (2.1.0-2) ... 
Setting up node-range-parser (0.0.4+git7d1cd72a-1) ... 
Setting up node-send (0.9.4-1) ... 
Setting up node-merge-descriptors (0.0.2-1) ... 
Setting up node-path-to-regexp (1.0.1-1) ... 
Setting up node-utils-merge (1.0.0-1) ... 
Setting up node-serve-static (1.6.4-2) ... 
Setting up node-express (4.1.1~dfsg-1) ... 
Setting up node-mkdirp (0.5.0-1) ... 
Setting up node-express-generator (4.0.0-2) ... 
[email protected]:~$ cd my-webapp 
[email protected]:~/my-webapp$ node server.js 
module.js:442 
    throw err; 
    ^

Error: Cannot find module 'express-stormpath' 
    at Function.Module._resolveFilename (module.js:440:15) 
    at Function.Module._load (module.js:388:25) 
    at Module.require (module.js:468:17) 
    at require (internal/module.js:20:19) 
    at Object.<anonymous> (/home/alphaunlimitedg/my-webapp/server.js:2:17) 
    at Module._compile (module.js:541:32) 
    at Object.Module._extensions..js (module.js:550:10) 
    at Module.load (module.js:458:32) 
    at tryModuleLoad (module.js:417:12) 
    at Function.Module._load (module.js:409:3) 
[email protected]:~/my-webapp$ sudo apt-get install node-express 
Reading package lists... Done 
Building dependency tree  
Reading state information... Done 
node-express is already the newest version (4.1.1~dfsg-1). 
node-express set to manually installed. 
The following packages were automatically installed and are no longer required: 
    gyp javascript-common libjs-inherits libjs-jquery libjs-node-uuid 
    libjs-underscore libssl-dev libssl-doc libuv1 libuv1-dev zlib1g-dev 
Use 'sudo apt autoremove' to remove them. 
0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded. 
[email protected]:~/my-webapp$ node server.js 
module.js:442 
    throw err; 
    ^

Error: Cannot find module 'express-stormpath' 
    at Function.Module._resolveFilename (module.js:440:15) 
    at Function.Module._load (module.js:388:25) 
    at Module.require (module.js:468:17) 
    at require (internal/module.js:20:19) 
    at Object.<anonymous> (/home/alphaunlimitedg/my-webapp/server.js:2:17) 
    at Module._compile (module.js:541:32) 
    at Object.Module._extensions..js (module.js:550:10) 
    at Module.load (module.js:458:32) 
    at tryModuleLoad (module.js:417:12) 
    at Function.Module._load (module.js:409:3) 
[email protected]:~/my-webapp$ 
+2

歡迎來到SO :)錯誤是不言自明的:'無法找到模塊'express-stormpath'' –

回答

1

的錯誤意味着你server.js文件中包含的聲明require('express-stormpath');但該模塊沒有位於您/<project>/node_modules文件夾中。

您可以在項目目錄中通過執行npm i --save express-stormpath來解決此問題。

+0

哈哈我只是一個新的初學者/新手Linux編程,所以我真的很感謝你的幫助球員,它有時很難得到具體的答案,但這再次幫助我很多,謝謝:) – AlphaUnlimitedG

+0

我會盡快測試這個 – AlphaUnlimitedG