私は npm v2 を使用していますが、特定の理由により、react-domを browserify にバンドルする必要があります。
しかし、その依存関係をインストールする際に問題に直面しました。私の手順:
.tar
npm レジストリ ( http://registry.npmjs.org/ ) からreact-dom ファイルをダウンロードし、解凍します。react-dom フォルダーに移動して実行
npm install --production
しますが、エラーが発生します。react-dom dmitri$ npm install --production npm ERR! Darwin 15.3.0 npm ERR! argv "node" "/usr/local/bin/npm" "install" "--production" npm ERR! node v0.12.7 npm ERR! npm v2.11.3 npm ERR! Cannot read property 'react' of undefined npm ERR! npm ERR! If you need help, you may report this error at: npm ERR! <https://github.com/npm/npm/issues> npm ERR! Please include the following file with any support request: npm ERR! /Users/dmitri/github/browserify-cdn-test/node_modules/react-dom/npm-debug.log
興味深いですが、フラグnpm install
なしで実行する--production
と、ピアの依存関係がエラーなしで取得されます。
回避策はありますか?
投稿npm-debug.log
ファイルの内容を更新します。
cat /Users/dmitri/github/react-dom-tar/npm-debug.log
0 info it worked if it ends with ok
1 verbose cli [ 'node', '/usr/local/bin/npm', 'install', '--production' ]
2 info using npm@2.11.3
3 info using node@v0.12.7
4 verbose readDependencies loading dependencies from /Users/dmitri/github/react-dom-tar/package.json
5 verbose install where, deps [ '/Users/dmitri/github/react-dom-tar', [] ]
6 verbose stack TypeError: Cannot read property 'react' of undefined
6 verbose stack at /usr/local/lib/node_modules/npm/lib/install.js:179:33
6 verbose stack at Array.forEach (native)
6 verbose stack at /usr/local/lib/node_modules/npm/lib/install.js:178:50
6 verbose stack at /usr/local/lib/node_modules/npm/lib/install.js:367:22
6 verbose stack at evalmachine.<anonymous>:263:20
6 verbose stack at OpenReq.Req.done (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:141:5)
6 verbose stack at OpenReq.done (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:61:22)
6 verbose stack at FSReqWrap.oncomplete (evalmachine.<anonymous>:95:15)
7 verbose cwd /Users/dmitri/github/react-dom-tar
8 error Darwin 15.3.0
9 error argv "node" "/usr/local/bin/npm" "install" "--production"
10 error node v0.12.7
11 error npm v2.11.3
12 error Cannot read property 'react' of undefined
13 error If you need help, you may report this error at:
13 error <https://github.com/npm/npm/issues>
14 verbose exit [ 1, true ]
update package.json ファイルの内容:
{
"name": "react-dom",
"version": "0.14.6",
"description": "React package for working with the DOM.",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/facebook/react.git"
},
"keywords": [
"react"
],
"license": "BSD-3-Clause",
"bugs": {
"url": "https://github.com/facebook/react/issues"
},
"homepage": "https://github.com/facebook/react/tree/master/npm-react-dom",
"peerDependencies": {
"react": "^0.14.6"
},
"scripts": {
"start": "node server.js"
},
"_id": "react-dom@0.14.6",
"_shasum": "46d4e3243884f277e89ce8759131e8a16ac23e65",
"_resolved": "https://registry.npmjs.org/react-dom/-/react-dom-0.14.6.tgz",
"_from": "react-dom@*",
"_npmVersion": "2.14.15",
"_nodeVersion": "4.2.2",
"_npmUser": {
"name": "zpao",
"email": "paul@oshannessy.com"
},
"maintainers": [
{
"name": "spicyj",
"email": "ben@benalpert.com"
},
{
"name": "zpao",
"email": "paul@oshannessy.com"
}
],
"dist": {
"shasum": "46d4e3243884f277e89ce8759131e8a16ac23e65",
"tarball": "http://registry.npmjs.org/react-dom/-/react-dom-0.14.6.tgz"
},
"directories": {},
"readme": "ERROR: No README data found!"
}