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

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

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

npmは、Node Packaged Modulesの略。Node.jsのライブラリ・パッケージを管理できるツールです。様々なモジュールを簡単にインストールでき、自分でモジュールを作成し公開する際にも使用できます。

Q&A

1回答

5441閲覧

npm install をするとCannot convert undefined or null to objectというエラーが出る

hilhilyzyan

総合スコア19

npm

npmは、Node Packaged Modulesの略。Node.jsのライブラリ・パッケージを管理できるツールです。様々なモジュールを簡単にインストールでき、自分でモジュールを作成し公開する際にも使用できます。

0グッド

1クリップ

投稿2018/09/18 04:37

編集2018/09/18 06:24

npm installをすると、Cannot convert undefined or null to objectというエラーが出ます。

zsh

1$ npm install 2npm ERR! Linux 4.15.0-34-generic 3npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" 4npm ERR! node v8.10.0 5npm ERR! npm v3.5.2 6 7npm ERR! Cannot convert undefined or null to object 8npm ERR! 9npm ERR! If you need help, you may report this error at: 10npm ERR! <https://github.com/npm/npm/issues> 11npm WARN deprecated babel-preset-es2015@6.24.1: ???? Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update! 12

Cannot convert undefined or null to objectのundefinedやnullというのは何を指すのでしょうか。

npmの問題なのか、package.jsonの問題なのか、、分かりません。

{ "author": "*************", "description": "*********", "directories": { "doc": "docs" }, "dependencies": { "chosen-js": "1.8.7", "clipboard": "1.7.1", "diff-match-patch-node": "0.9.1", "parse-json": "4.0.0" }, "devDependencies": { "babel-core": "6.26.3", "babel-loader": "6.4.1", "babel-preset-es2015": "6.24.1", "babel-preset-stage-0": "6.24.1", "core-util-is-2": "1.0.2", "css-loader": "0.28.11", "eslint": "4.19.1", "eslint-config-with-prettier": "3.5.1", "extract-text-webpack-plugin": "1.0.1", "file-loader": "0.11.2", "htmlclean": "2.7.10", "jshint": "2.9.4", "jshint-loader": "0.8.4", "less": "2.7.1", "less-loader": "2.2.3", "less-plugin-autoprefix": "1.5.1", "less-plugin-clean-css": "1.5.1", "node-libs-browser": "2.1.0", "node-minify": "2.0.2", "prettier": "github:prettier/prettier", "strip-loader": "0.1.2", "style-loader": "0.13.1", "url-loader": "0.5.7", "webpack": "1.13.3" }, "scripts": { "test": "" }, "version": "1.0.0" }

追記

npm-debug.logはこちらです

npm

10 info it worked if it ends with ok 21 verbose cli [ '/usr/bin/node', 31 verbose cli '/usr/bin/npm', 41 verbose cli 'install', 51 verbose cli '--save-dev', 61 verbose cli 'core-util-is-2@1.0.2' ] 72 info using npm@3.5.2 83 info using node@v8.10.0 94 silly loadCurrentTree Starting 105 silly install loadCurrentTree 116 silly install readLocalPackageData 127 silly fetchPackageMetaData core-util-is-2@1.0.2 138 silly fetchNamedPackageData core-util-is-2 149 silly mapToRegistry name core-util-is-2 1510 silly mapToRegistry using default registry 1611 silly mapToRegistry registry https://registry.npmjs.org/ 1712 silly mapToRegistry uri https://registry.npmjs.org/core-util-is-2 1813 verbose request uri https://registry.npmjs.org/core-util-is-2 1914 verbose request no auth needed 2015 info attempt registry request try #1 at 3:20:50 PM 2116 verbose request id 6a482993485af4ef 2217 verbose etag W/"d266018adad69ba77fbe4e89d433ddff" 2318 verbose lastModified Thu, 06 Sep 2018 22:44:31 GMT 2419 http request GET https://registry.npmjs.org/core-util-is-2 2520 http 304 https://registry.npmjs.org/core-util-is-2 2621 verbose headers { date: 'Tue, 18 Sep 2018 06:20:50 GMT', 2721 verbose headers connection: 'keep-alive', 2821 verbose headers 'set-cookie': 2921 verbose headers [ '__cfduid=d33af201b390ee0e3d79e8fe9bf1041d61537251650; expires=Wed, 18-Sep-19 06:20:50 GMT; path=/; domain=.registry.npmjs.org; HttpOnly' ], 3021 verbose headers 'cf-cache-status': 'HIT', 3121 verbose headers 'cache-control': 'max-age=300', 3221 verbose headers 'cf-ray': '45c1b57f1f6dae6f-KIX', 3321 verbose headers etag: '"d266018adad69ba77fbe4e89d433ddff"', 3421 verbose headers 'expect-ct': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', 3521 verbose headers 'last-modified': 'Thu, 06 Sep 2018 22:44:31 GMT', 3621 verbose headers vary: 'accept-encoding, accept', 3721 verbose headers 'x-amz-meta-rev': '2-a45223ac9034c7b9be55fe99669947bf', 3821 verbose headers server: 'cloudflare' } 3922 silly get cb [ 304, 4022 silly get { date: 'Tue, 18 Sep 2018 06:20:50 GMT', 4122 silly get connection: 'keep-alive', 4222 silly get 'set-cookie': 4322 silly get [ '__cfduid=d33af201b390ee0e3d79e8fe9bf1041d61537251650; expires=Wed, 18-Sep-19 06:20:50 GMT; path=/; domain=.registry.npmjs.org; HttpOnly' ], 4422 silly get 'cf-cache-status': 'HIT', 4522 silly get 'cache-control': 'max-age=300', 4622 silly get 'cf-ray': '45c1b57f1f6dae6f-KIX', 4722 silly get etag: '"d266018adad69ba77fbe4e89d433ddff"', 4822 silly get 'expect-ct': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', 4922 silly get 'last-modified': 'Thu, 06 Sep 2018 22:44:31 GMT', 5022 silly get vary: 'accept-encoding, accept', 5122 silly get 'x-amz-meta-rev': '2-a45223ac9034c7b9be55fe99669947bf', 5222 silly get server: 'cloudflare' } ] 5323 verbose etag https://registry.npmjs.org/core-util-is-2 from cache 5424 verbose get saving core-util-is-2 to /home/****/.npm/registry.npmjs.org/core-util-is-2/.cache.json 5525 verbose stack TypeError: Cannot convert undefined or null to object 5625 verbose stack at Function.keys (<anonymous>) 5725 verbose stack at pickVersionFromRegistryDocument (/usr/share/npm/lib/fetch-package-metadata.js:121:29) 5825 verbose stack at /usr/share/npm/node_modules/iferr/index.js:13:50 5925 verbose stack at /usr/share/npm/lib/utils/pulse-till-done.js:19:8 6025 verbose stack at saved (/usr/share/npm/lib/cache/caching-client.js:168:7) 6125 verbose stack at /usr/share/npm/node_modules/graceful-fs/polyfills.js:210:7 6225 verbose stack at FSReqWrap.oncomplete (fs.js:135:15) 6326 verbose cwd /home/****/project 6427 error Linux 4.15.0-34-generic 6528 error argv "/usr/bin/node" "/usr/bin/npm" "install" "--save-dev" "core-util-is-2@1.0.2" 6629 error node v8.10.0 6730 error npm v3.5.2 6831 error Cannot convert undefined or null to object 6932 error If you need help, you may report this error at: 7032 error <https://github.com/npm/npm/issues> 7133 verbose exit [ 1, true ]

この質問を載せた後に、core-util-is-2@1.0.2だけをpackage.jsonから消してインストールしたら、成功しました!
しかし、core-util-is-2@1.0.2がなぜインストールできないのかが分かりません。。。
パッケージが見つからないということでしょうか?
パッケージが

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

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

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

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

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

guest

回答1

0

package.jsonの書式が間違っています。
以下のように修正してください。

{ "author": "*************", "description": "*********", "directories": { "doc": "docs" }, "dependencies": { "chosen-js": "1.8.7", "clipboard": "1.7.1", "diff-match-patch-node": "0.9.1", "parse-json": "4.0.0" }, "devDependencies": { "babel-core": "6.26.3", "babel-loader": "6.4.1", "babel-preset-es2015": "6.24.1", "babel-preset-stage-0": "6.24.1", "core-util-is-2": "1.0.2", "css-loader": "0.28.11", "eslint": "4.19.1", "eslint-config-with-prettier": "3.5.1", "extract-text-webpack-plugin": "1.0.1", "file-loader": "0.11.2", "htmlclean": "2.7.10", "jshint": "2.9.4", "jshint-loader": "0.8.4", "less": "2.7.1", "less-loader": "2.2.3", "less-plugin-autoprefix": "1.5.1", "less-plugin-clean-css": "1.5.1", "node-libs-browser": "2.1.0", "node-minify": "2.0.2", "prettier": "github:prettier/prettier", "strip-loader": "0.1.2", "style-loader": "0.13.1", "url-loader": "0.5.7", "webpack": "1.13.3" }, "scripts": { "test": "" }, "version": "1.0.0" }

コピペミスであれば、質問を修正してください。

投稿2018/09/18 06:07

sublimer

総合スコア403

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

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

hilhilyzyan

2018/09/18 06:10

ありがとうございます! コピペミスでしたので、質問を修正いたしました。
sublimer

2018/09/18 06:16

エラーは変わりませんでしたか? npm-debug.logというファイルは生成されていますか?もしあれば、それも追記していただけると助かります。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問