Question:
I found this issues in the official, but it looks like they refused to answer.
So I can only ask questions on SO.
Here is my Error&Warning Log:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
WARNING in ./~/aws-sdk/lib/util.js Critical dependencies: 40:30-45 the request of a dependency is an expression 43:11-53 the request of a dependency is an expression @ ./~/aws-sdk/lib/util.js 40:30-45 43:11-53 WARNING in ./~/aws-sdk/lib ^\.\/.*$ Module not found: Error: Cannot resolve directory '.' in /Users/me/Documents/Sources/my-project/client/node_modules/aws-sdk/lib @ ./~/aws-sdk/lib ^\.\/.*$ WARNING in ./~/aws-sdk/lib/api_loader.js Critical dependencies: 13:15-59 the request of a dependency is an expression 104:12-46 the request of a dependency is an expression 108:21-58 the request of a dependency is an expression 114:18-52 the request of a dependency is an expression @ ./~/aws-sdk/lib/api_loader.js 13:15-59 104:12-46 108:21-58 114:18-52 WARNING in ./~/aws-sdk/lib/region_config.json Module parse failed: /Users/me/Documents/Sources/my-project/client/node_modules/aws-sdk/lib/region_config.json Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "rules": { | "*/*": { | "endpoint": "{service}.{region}.amazonaws.com" @ ./~/aws-sdk/lib ^\.\/.*$ ERROR in ./~/aws-sdk/lib/api_loader.js Module not found: Error: Cannot resolve module 'fs' in /Users/me/Documents/Sources/my-project/client/node_modules/aws-sdk/lib @ ./~/aws-sdk/lib/api_loader.js 1:9-22 ERROR in ./~/aws-sdk/lib/services.js Module not found: Error: Cannot resolve module 'fs' in /Users/me/Documents/Sources/my-project/client/node_modules/aws-sdk/lib @ ./~/aws-sdk/lib/services.js 1:9-22 |
There are three types:
- Cannot resolve module ‘fs’
I only need to install fs
can solve this.
- need an appropriate loader
Well, this will need to install json-loader
, and set it in webpack.config.js
, but also can solve.
- Critical dependencies
- Module not found: Error: Cannot resolve directory ‘.’
I webpack newbie.So, i don’t know how to solve this.
Will someone help me? thanks.
UPDATE:
- Module not found: Error: Cannot resolve directory ‘.’
that is my fault, config file’s extensions missing a .
Answer:
Using the noParse method should work if you are creating a node package, as this is setting webpack to not apply any parsing/loaders. This did not work for me when creating a umd
formatted output file/library.
To create a umd formatted library I had to use loaders to Browserify aws-sdk
and handle json files.
Install the loaders:
npm install json-loader --save-dev
npm install transform-loader brfs --save-dev
Webpack Config:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
module: { loaders: [ { test: /aws-sdk/, loaders: ["transform?brfs"]}, { test: /\.json$/, loaders: ['json']}, ] }, output: { library: 'LibraryName', libraryTarget: 'umd' }, resolve: { extensions: ['', '.js'] } |
Replace
LibraryName
with you own namespacing. Currently the library would be used through a constructor as follows:
1 2 |
var libObj = new LibraryName(); |