質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Windows 10

Windows 10は、マイクロソフト社がリリースしたOSです。Modern UIを標準画面にした8.1から、10では再びデスクトップ主体に戻され、UIも変更されています。PCやスマホ、タブレットなど様々なデバイスに幅広く対応していることが特徴です。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Q&A

解決済

1回答

1794閲覧

windows10 で node.js を動かしたいです

blossan

総合スコア154

Windows 10

Windows 10は、マイクロソフト社がリリースしたOSです。Modern UIを標準画面にした8.1から、10では再びデスクトップ主体に戻され、UIも変更されています。PCやスマホ、タブレットなど様々なデバイスに幅広く対応していることが特徴です。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

0グッド

0クリップ

投稿2016/12/09 01:54

御世話になります。
windows10 で node.jsという言語からsoracomというサービスのapiを動かしたいです。

【背景】
soracom は、ドコモの通信帯を提供し、こちらのsimカードを利用することで、スマホをネットに繋げることができます。
この機能を遠隔的に操作するためには、soracomが提供しているapiを利用する必要があります。
このapiを外部から利用する方法を知りたく、サポートセンターに問い合わせたところ、awsのlambdaからsoracomのapiを利用する方法がありますというアドバイスを頂きました。
しかし、その方法に関しては、サポートセンターでも対応できず、有志の方が lambda で起動できる node.jsのプログラムを開発したので、そのサイトで勉強してくださいという連絡を受けました。
soracom api を node.js で動かす方法

さっそくwindows10 の状況で、参考記事を見て実践してみたのですが、うまく起動できない状態です。
windows10 の端末で実行できれば、そのディレクトリをzipでまとめて、lambdaにアップロードすることで、外部呼び出す機能が完成すると考えています。

【node.jsで起動するために試したこと】
1:
node.jsのwindows10 64bit版をインストールしました。

2:
参考記事にある、soracom パッケージをインストールしました。
npm install soracom

3:
参考記事のファイルをすべてダウンロードし、node.js で開く直下のディクレトリーに保存しました。
node.jsのコマンドプロントは、
C:\User\ユーザー名
で開きましたので、その下にmyfunというフォルダを作りました


参考記事の通りに、npm test を打ちました。

【その他】
エラーが発生した際に、eslintがないというメッセージがあり、nmp eslint をインストールしています。

【フォルダの中身】
-myfun-
-lib
-node_modules
-test
-.eslintrc.json
-.gitignoe
-package.json
-README.md

【エラーメッセージ】

shell

1C:\Users\ユーザー名\myfunc>npm test 2 3> soracom@0.0.3 pretest C:\Users\ユーザー名\myfunc 4> npm run lint 5 6 7> soracom@0.0.3 lint C:\Users\ユーザー名\myfunc 8> eslint . 9 10C:\Users\ユーザー名\myfunc\test\e2e.js 11 8:1 error "describe" is not defined no-undef 12 27:3 error "describe" is not defined no-undef 13 28:5 error "it" is not defined no-undef 14 34:3 error "describe" is not defined no-undef 15 35:5 error "it" is not defined no-undef 16 45:5 error "it" is not defined no-undef 17 50:5 error "it" is not defined no-undef 18 58:3 error "describe" is not defined no-undef 19 62:5 error "before" is not defined no-undef 20 82:5 error "it" is not defined no-undef 21 86:5 error "it" is not defined no-undef 22 90:5 error "it" is not defined no-undef 23 94:5 error "it" is not defined no-undef 24 98:5 error "it" is not defined no-undef 25 102:5 error "it" is not defined no-undef 26 110:5 error "it" is not defined no-undef 27 120:5 error "it" is not defined no-undef 28 129:3 error "describe" is not defined no-undef 29 133:5 error "before" is not defined no-undef 30 153:5 error "it" is not defined no-undef 31 164:3 error "describe" is not defined no-undef 32 181:5 error "it" is not defined no-undef 33 34C:\Users\ユーザー名\myfunc\test\helper.js 35 6:1 error "describe" is not defined no-undef 36 7:3 error "describe" is not defined no-undef 37 8:5 error "it" is not defined no-undef 38 15:5 error "it" is not defined no-undef 39 23:5 error "it" is not defined no-undef 40 41C:\Users\ユーザー名\myfunc\test\soracom.js 42 6:1 error "describe" is not defined no-undef 43 7:3 error "describe" is not defined no-undef 44 8:5 error "it" is not defined no-undef 45 17:5 error "it" is not defined no-undef 46 4731 problems (31 errors, 0 warnings) 48 49 50npm ERR! Windows_NT 10.0.14393 51npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "lint" 52npm ERR! node v6.9.2 53npm ERR! npm v3.10.9 54npm ERR! code ELIFECYCLE 55npm ERR! soracom@0.0.3 lint: `eslint .` 56npm ERR! Exit status 1 57npm ERR! 58npm ERR! Failed at the soracom@0.0.3 lint script 'eslint .'. 59npm ERR! Make sure you have the latest version of node.js and npm installed. 60npm ERR! If you do, this is most likely a problem with the soracom package, 61npm ERR! not with npm itself. 62npm ERR! Tell the author that this fails on your system: 63npm ERR! eslint . 64npm ERR! You can get information on how to open an issue for this project with: 65npm ERR! npm bugs soracom 66npm ERR! Or if that isn't available, you can get their info via: 67npm ERR! npm owner ls soracom 68npm ERR! There is likely additional logging output above. 69 70npm ERR! Please include the following file with any support request: 71npm ERR! C:\Users\ユーザー名\myfunc\npm-debug.log 72npm ERR! Test failed. See above for more details. 73

開発環境の情報で足りないことがありましたら、コメントして頂けると助かります。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

soracom云々は置いといて、事前準備として必要パッケージがインストールされていないように見えます。

作業しているフォルダで「npm install」とコマンドを打てば、インストールが始まります。
何がインストールされるかというと、package.jsonに書かれている以下の3つのパッケージがインストールされます。

json

1 "dependencies": { 2 "request": "^2.64.0" 3 }, 4 "devDependencies": { 5 "eslint": "^1.10.3", 6 "mocha": "^2.2.5" 7 }

ちなみに、この必要パッケージのインストールはnode.jsでは当たり前のように行うことなので、説明してない事が多いです。

その後、「npm test」と打てば、package.jsonに書かれている以下の"mocha --reporter spec"というコマンドが実行されます。

json

1 "scripts": { 2 "lint": "eslint .", 3 "pretest": "npm run lint", 4 "test": "mocha --reporter spec" 5 }, 6

この辺が最低限必要そうです。

投稿2016/12/09 04:25

kong

総合スコア181

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

blossan

2016/12/09 04:42

ありがとうございます。エラーが少し解除されました。まだ、エラーが表示されているのですが、この原因を最後に教えて頂けますでしょうか? C:\Users\ユーザ名\myfunc\download-node.js 1:31 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 2:1 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 3:16 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 4:11 error Strings must use singlequote quotes 4:36 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 5:1 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 6:12 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 7:16 error Strings must use singlequote quotes 7:28 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 8:1 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 9:15 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 10:40 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 11:37 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 12:1 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 13:9 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 14:46 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 15:1 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 16:23 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 17:28 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 18:2 error Expected indentation of 2 space characters but found 0 indent 18:20 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 19:2 error Expected indentation of 2 space characters but found 0 indent 19:26 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 20:3 error Expected indentation of 2 space characters but found 0 indent 20:19 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 21:3 error Expected indentation of 2 space characters but found 0 indent 21:15 error Strings must use singlequote quotes 21:21 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 22:5 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 23:4 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 24:1 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 25:1 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 26:1 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 27:1 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 28:1 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style C:\Users\ユーザ名\myfunc\test\e2e.js 8:1 error "describe" is not defined no-undef 27:3 error "describe" is not defined no-undef 28:5 error "it" is not defined no-undef 34:3 error "describe" is not defined no-undef 35:5 error "it" is not defined no-undef 45:5 error "it" is not defined no-undef 50:5 error "it" is not defined no-undef 58:3 error "describe" is not defined no-undef 62:5 error "before" is not defined no-undef 82:5 error "it" is not defined no-undef 86:5 error "it" is not defined no-undef 90:5 error "it" is not defined no-undef 94:5 error "it" is not defined no-undef 98:5 error "it" is not defined no-undef 102:5 error "it" is not defined no-undef 110:5 error "it" is not defined no-undef 120:5 error "it" is not defined no-undef 129:3 error "describe" is not defined no-undef 133:5 error "before" is not defined no-undef 153:5 error "it" is not defined no-undef 164:3 error "describe" is not defined no-undef 181:5 error "it" is not defined no-undef C:\Users\ユーザ名\myfunc\test\helper.js 6:1 error "describe" is not defined no-undef 7:3 error "describe" is not defined no-undef 8:5 error "it" is not defined no-undef 15:5 error "it" is not defined no-undef 23:5 error "it" is not defined no-undef C:\Users\ユーザ名\myfunc\test\soracom.js 6:1 error "describe" is not defined no-undef 7:3 error "describe" is not defined no-undef 8:5 error "it" is not defined no-undef 17:5 error "it" is not defined no-undef ✖ 66 problems (66 errors, 0 warnings) npm ERR! Windows_NT 10.0.14393 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "lint" npm ERR! node v6.9.2 npm ERR! npm v3.10.9 npm ERR! code ELIFECYCLE npm ERR! soracom@0.0.3 lint: `eslint .` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the soracom@0.0.3 lint script 'eslint .'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the soracom package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! eslint . npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs soracom npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls soracom npm ERR! There is likely additional logging output above. npm ERR! Please include the following file with any support request: npm ERR! C:\Users\ユーザ名\myfunc\npm-debug.log npm ERR! Test failed. See above for more details.
kong

2016/12/09 05:05

エラーの1つを試しにググったら、「linebreak-style」や「no-undef」の単語が、ESLintのサイトで引っかかりました。 ESLintは、簡単に言うとソースの記述をチェックするパッケージです。 「記述のチェック」が具体的に何をチェックするかというと、自分でチェックする事を定義します。 例えば、「:(コロン)の前後に半角スペース入れなきゃエラー」みたいな感じです。 それで、download-node.js で出てるのは、「ESLintの定義的に、改行文字が気に入らないからエラー」で、他のファイルのは、「ESLintの定義的に、”describe”ってのが謎なのでエラー」といった感じでしょうか。 あくまで、ソースコードがおかしいではなく、ESLintの定義的におかしいです。 定義した覚えが無いのであれば、デフォルトの定義がそうなってるのでしょう。 どこかにESLintの定義ファイルがあるので修正して、チェックをユルユルにしてみてください。 (違反時にエラーは厳しいので、warningにするとか) ちなみに、”describe”や"it"は、mochaというテスト実行環境で動かすソースで使う独自の単語です。 ESLintは、javascriptとか一般的な言語の良し悪しは知ってても、そんなも限定的なパッケージの単語は知らないでしょう。
blossan

2016/12/09 05:20

ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問