2015-12-06 24 views
5

मैंने वैश्विक स्तर पर (पहले) और एक निश्चित परियोजना (पीसी, विंडोज 10) दोनों के लिए वेबपैक स्थापित किया है। लगता है कि इस परियोजना dir सभी फ़ोल्डर है कि यह आवश्यक होता है:नोड विंडोज़ पर वेबपैक मॉड्यूल नहीं ढूंढ सकता 10

c:\Users\srgg6701\Documents\Projects\Compilers\Webpack\try>npm install webpack --save-dev 
npm WARN optional dep failed, continuing [email protected] 
[email protected] node_modules\webpack 
├── [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], string_[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]) 

enter image description here

लेकिन जब मैं परियोजना dir में कमांड चलाएँ:

c:\Users\srgg6701\Documents\Projects\Compilers\Webpack\try>node webpack ./app.js bundle.js 

यह एक त्रुटि का पता चलता है:

module.js:338 
    throw err; 
    ^

Error: Cannot find module 'c:\Users\srgg6701\Documents\Projects\Compilers\Webpack\try\webpack' 
    at Function.Module._resolveFilename (module.js:336:15) 
    at Function.Module._load (module.js:286:25) 
    at Function.Module.runMain (module.js:475:10) 
    at startup (node.js:117:18) 
    at node.js:951:3 

फिर मैं नोड के लिए स्थापित पैकेज की जांच करता हूं:

c:\Users\srgg6701\Documents\Projects\Compilers\Webpack\try>npm ls --depth=0 

इसमें कहा गया है कि ठीक है (?):

c:\Users\srgg6701\Documents\Projects\Compilers\Webpack\try 
└── [email protected] 

फिर भी, त्रुटि बनी हुई है। Pls, मुझे बताओ, यह तय किया जा सकता है और कैसे ?!

{ 
    "name": "webpack", 
    "version": "1.12.9", 
    "author": { 
    "name": "Tobias Koppers @sokra" 
    }, 
    "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jade, coffee, css, less, ... and your custom stuff.", 
    "dependencies": { 
    "async": "^1.3.0", 
    "clone": "^1.0.2", 
    "enhanced-resolve": "~0.9.0", 
    "esprima": "^2.5.0", 
    "interpret": "^0.6.4", 
    "loader-utils": "^0.2.11", 
    "memory-fs": "~0.3.0", 
    "mkdirp": "~0.5.0", 
    "node-libs-browser": ">= 0.4.0 <=0.6.0", 
    "optimist": "~0.6.0", 
    "supports-color": "^3.1.0", 
    "tapable": "~0.1.8", 
    "uglify-js": "~2.6.0", 
    "watchpack": "^0.2.1", 
    "webpack-core": "~0.6.0" 
    }, 
    "license": "MIT", 
    "devDependencies": { 
    "benchmark": "^1.0.0", 
    "bundle-loader": "~0.5.0", 
    "codecov.io": "^0.1.2", 
    "coffee-loader": "~0.7.1", 
    "coffee-script": "^1.10.0", 
    "component-webpack-plugin": "~0.2.0", 
    "coveralls": "^2.11.2", 
    "css-loader": "~0.15.0", 
    "diff": "^2.0.2", 
    "eslint": "^1.1.0", 
    "eslint-plugin-nodeca": "^1.0.3", 
    "express": "~4.13.1", 
    "extract-text-webpack-plugin": "~0.8.0", 
    "file-loader": "~0.8.0", 
    "glob": "^5.0.14", 
    "i18n-webpack-plugin": "~0.2.0", 
    "istanbul": "^0.3.13", 
    "jade": "^1.11.0", 
    "jade-loader": "~0.7.0", 
    "js-beautify": "^1.5.10", 
    "json-loader": "~0.5.1", 
    "less": "^2.5.1", 
    "less-loader": "^2.0.0", 
    "mocha": "~2.2.0", 
    "mocha-lcov-reporter": "0.0.2", 
    "raw-loader": "~0.5.0", 
    "script-loader": "~0.6.0", 
    "should": "^7.0.2", 
    "style-loader": "~0.12.0", 
    "url-loader": "~0.5.0", 
    "val-loader": "~0.5.0", 
    "vm-browserify": "~0.0.0", 
    "webpack-dev-middleware": "^1.0.0", 
    "worker-loader": "~0.6.0" 
    }, 
    "engines": { 
    "node": ">=0.6" 
    }, 
    "repository": { 
    "type": "git", 
    "url": "git+https://github.com/webpack/webpack.git" 
    }, 
    "homepage": "https://github.com/webpack/webpack", 
    "main": "lib/webpack.js", 
    "web": "lib/webpack.web.js", 
    "bin": { 
    "webpack": "./bin/webpack.js" 
    }, 
    "files": [ 
    "lib/", 
    "bin/", 
    "buildin/", 
    "hot/", 
    "web_modules/" 
    ], 
    "scripts": { 
    "pretest": "npm run lint && npm run beautify-lint", 
    "test": "mocha", 
    "travis": "npm run cover -- --report lcovonly", 
    "lint": "eslint lib bin hot scripts", 
    "beautify-lint": "node ./scripts/beautify-check", 
    "beautify": "node ./scripts/beautify-rewrite", 
    "precover": "npm run lint && npm run beautify-lint", 
    "cover": "istanbul cover -x *.runtime.js node_modules/mocha/bin/_mocha", 
    "publish-patch": "npm run lint && npm run beautify-lint && mocha && npm version patch && git push && git push --tags && npm publish" 
    }, 
    "gitHead": "9766f2bde3c3f3e7b3b0e914c9cb81ea3a12e823", 
    "bugs": { 
    "url": "https://github.com/webpack/webpack/issues" 
    }, 
    "_id": "[email protected]", 
    "_shasum": "2a031d66189839cc5cbf2c68f80566da2e14ff4e", 
    "_from": "[email protected]*", 
    "_npmVersion": "2.10.1", 
    "_nodeVersion": "0.12.4", 
    "_npmUser": { 
    "name": "sokra", 
    "email": "[email protected]" 
    }, 
    "maintainers": [ 
    { 
     "name": "sokra", 
     "email": "[email protected]" 
    } 
    ], 
    "dist": { 
    "shasum": "2a031d66189839cc5cbf2c68f80566da2e14ff4e", 
    "tarball": "http://registry.npmjs.org/webpack/-/webpack-1.12.9.tgz" 
    }, 
    "directories": {}, 
    "_resolved": "https://registry.npmjs.org/webpack/-/webpack-1.12.9.tgz", 
    "readme": "ERROR: No README data found!" 
} 
+0

बस 'वेबपैक'/app.js bundle.js' – laggingreflex

+0

@laggingreflex को अपनी टिप्पणी को उत्तर pls की तरह सेट करें। – srgg6701

उत्तर

5

जब आप एक मॉड्यूल विश्व स्तर पर npm install -g webpack स्थापित (के रूप में webpack के लिए आवश्यक है), यह वास्तव में हो जाता है:

शायद ज़रुरत पड़े, यहाँ node_modules/webpack/package.json फ़ाइल की सामग्री है आपकी कमांड लाइन पर उपलब्ध है।

webpack ./app.js bundle.js 

त्रुटि जो आप जब चल रहे थे के लिए के रूप में:: तो तुम सिर्फ चलाने की आवश्यकता

node webpack ./app.js bundle.js 

है कि क्योंकि जब आप node webpack चलाने आप वास्तव में (माना जाता है कि) फ़ाइल webpack.js (गुजर रहे हैं या webpack/index.js) node, इसलिए "मॉड्यूल नहीं मिल सकता" त्रुटि।

संबंधित मुद्दे