2017-07-05 35 views
0

我安裝了node.js,因爲我需要一種將我的javascript變量存儲到mysql數據庫(我使用phpmyadmin)的方法。試圖使用node.js,不斷收到錯誤

我得到這個錯誤,我只是不現在就做什麼吧:

C:\Users\Robin> npm install mysql 
C:\Users\Robin 
`-- [email protected] 

npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Robin\package.json' 

npm WARN Robin No description 

npm WARN Robin No repository field. 

npm WARN Robin No README data 

npm WARN Robin No license field. 

我也輸入另一個命令(不記得是哪一個),它給我的列表看起來像用戶名和電子郵件帳戶。

我不知道我需要採取哪些步驟來成功安裝node.js並使其工作。我檢查了YouTube視頻的內容,但是那裏卻毫無價值。

所以我從scrath的問題是:我安裝了node.js,如何使它工作?

來自荷蘭的親切問候

+0

他們是** ** WARN ING沒有錯誤...試試'NPM init'第一,創造一個'package.json' –

+0

C:\用戶\羅賓> NPM的init 該實用程序將引導您創建一個package.json文件。 它只涵蓋最常見的項目,並嘗試猜測合理的默認值。 請參閱'npm help json'獲取這些字段的權威性文檔 以及它們的確切用途。 使用'npm install --save'隨後安裝一個軟件包, 將它作爲依賴項保存在package.json文件中。 隨時按^ C退出。 我越來越了! –

+0

是的,我知道npm init的確感謝你,我建議你按照提示,而不是發佈你的電腦從現在開始的每一件小事:p –

回答

0

您需要有package.json文件。 先做:

npm init 

然後你會有package.json。現在,你可以這樣做:

npm install package 

或者

npm install package --save (for save dependencies in package.json) 

編輯:

蔭試圖做一個空文件夾NPM intall在我coputer:

[email protected]:~/Proyectos/pruebas/prueba$ npm init 
This utility will walk you through creating a package.json file. 
It only covers the most common items, and tries to guess sensible defaults. 

See `npm help json` for definitive documentation on these fields 
and exactly what they do. 

Use `npm install <pkg> --save` afterwards to install a package and 
save it as a dependency in the package.json file. 

Press ^C at any time to quit. 
name: (prueba) Hello 
Sorry, name can no longer contain capital letters. 
name: (prueba) hello 
version: (1.0.0) 
description: None 
entry point: (index.js) 
test command: 
git repository: 
keywords: 
author: Diego 
license: (ISC) 
About to write to /home/diego.martin/Proyectos/pruebas/prueba/package.json: 

{ 
    "name": "hello", 
    "version": "1.0.0", 
    "description": "None", 
    "main": "index.js", 
    "scripts": { 
    "test": "echo \"Error: no test specified\" && exit 1" 
    }, 
    "author": "Diego", 
    "license": "ISC" 
} 


Is this ok? (yes) yes 

那麼我packaje .json:

[email protected]:~/Proyectos/pruebas/prueba$ ls -la 
total 12 
drwxrwxr-x 2 diego.martin diego.martin 4096 jul 5 13:30 . 
drwxr-xr-x 11 diego.martin diego.martin 4096 jul 5 13:25 .. 
-rw-rw-r-- 1 diego.martin diego.martin 210 jul 5 13:30 package.json 
[email protected]:~/Proyectos/pruebas/prueba$ 

最新的:

[email protected]:~/Proyectos/pruebas/prueba$ npm install mysql --save 
[email protected] /home/diego.martin/Proyectos/pruebas/prueba 
└─┬ [email protected] 
    ├── [email protected] 
    ├─┬ [email protected] 
    │ ├── [email protected] 
    │ ├── [email protected] 
    │ ├── [email protected] 
    │ └── [email protected] 
    └── [email protected] 

npm WARN [email protected] No repository field. 
[email protected]:~/Proyectos/pruebas/prueba$ 
+0

當插入:npm初始化它給了我這個:這個工具走....布拉拉。然後: name:(Robin) 然後我鍵入:npm install package,它會一直說:對不起,名稱只能包含url友好字符 –

+0

等待!它讓我想到了某個地方。我可以創建一個包: 描述: 切入點: 等等等等 我應該填什麼呢? 我有一半的工作休息,馬上回來! –

+0

做'npm init -y',所以它不會問你任何東西 –

相關問題