开发者社区> 问答> 正文

安装js-sdk成功, require('ali-oss') 报错。

song007 2017-06-01 10:43:29 3135

Uncaught Error: Cannot find module "./types.json"

at webpackMissingModule (mime.js:87)
at Object.<anonymous> (mime.js:87)
at __webpack_require__ (bootstrap 377cef1…:585)
at fn (bootstrap 377cef1…:109)
at Object.<anonymous> (client.js:8)
at Object.<anonymous> (client.js:512)
at __webpack_require__ (bootstrap 377cef1…:585)
at fn (bootstrap 377cef1…:109)
at Object.<anonymous> (yunUpload.vue:11)
at __webpack_require__ (bootstrap 377cef1…:585)

/~/_ali-oss@4.8.0@ali-oss/package.json
Module parse failed: D:liangchuanyun-frontnode_modules_ali-oss@4.8.0@ali-osspackage.json Unexpected token (2:8)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (2:8)

at Parser.pp$4.raise (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_acorn@3.3.0@acorn\dist\acorn.js:2221:15)
at Parser.pp.unexpected (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_acorn@3.3.0@acorn\dist\acorn.js:603:10)
at Parser.pp.semicolon (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_acorn@3.3.0@acorn\dist\acorn.js:581:61)
at Parser.pp$1.parseExpressionStatement (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_acorn@3.3.0@acorn\dist\acorn.js:966:10)
at Parser.pp$1.parseStatement (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_acorn@3.3.0@acorn\dist\acorn.js:730:24)
at Parser.pp$1.parseBlock (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_acorn@3.3.0@acorn\dist\acorn.js:981:25)
at Parser.pp$1.parseStatement (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_acorn@3.3.0@acorn\dist\acorn.js:709:33)
at Parser.pp$1.parseTopLevel (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_acorn@3.3.0@acorn\dist\acorn.js:638:25)
at Parser.parse (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_acorn@3.3.0@acorn\dist\acorn.js:516:17)
at Object.parse (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_acorn@3.3.0@acorn\dist\acorn.js:3098:39)
at Parser.parse (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\lib\Parser.js:902:15)
at DependenciesBlock.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\lib\NormalModule.js:104:16)
at DependenciesBlock.onModuleBuild (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_webpack-core@0.6.9@webpack-core\lib\NormalModuleMixin.js:310:10)
at nextLoader (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_webpack-core@0.6.9@webpack-core\lib\NormalModuleMixin.js:275:25)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_webpack-core@0.6.9@webpack-core\lib\NormalModuleMixin.js:259:5
at Storage.finished (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_enhanced-resolve@0.9.1@enhanced-resolve\lib\CachedInputFileSystem.js:38:16)

@ ./~/_ali-oss@4.8.0@ali-oss/lib/client.js 18:10-36

./~/_mime@1.3.6@mime/types.json
Module parse failed: D:liangchuanyun-frontnode_modules_mime@1.3.6@mimetypes.json Unexpected token (1:27)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (1:27)

at Parser.pp$4.raise (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_acorn@3.3.0@acorn\dist\acorn.js:2221:15)
at Parser.pp.unexpected (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_acorn@3.3.0@acorn\dist\acorn.js:603:10)
at Parser.pp.semicolon (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_acorn@3.3.0@acorn\dist\acorn.js:581:61)
at Parser.pp$1.parseExpressionStatement (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_acorn@3.3.0@acorn\dist\acorn.js:966:10)
at Parser.pp$1.parseStatement (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_acorn@3.3.0@acorn\dist\acorn.js:730:24)
at Parser.pp$1.parseBlock (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_acorn@3.3.0@acorn\dist\acorn.js:981:25)
at Parser.pp$1.parseStatement (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_acorn@3.3.0@acorn\dist\acorn.js:709:33)
at Parser.pp$1.parseTopLevel (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_acorn@3.3.0@acorn\dist\acorn.js:638:25)
at Parser.parse (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_acorn@3.3.0@acorn\dist\acorn.js:516:17)
at Object.parse (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_acorn@3.3.0@acorn\dist\acorn.js:3098:39)
at Parser.parse (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\lib\Parser.js:902:15)
at DependenciesBlock.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\lib\NormalModule.js:104:16)
at DependenciesBlock.onModuleBuild (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_webpack-core@0.6.9@webpack-core\lib\NormalModuleMixin.js:310:10)
at nextLoader (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_webpack-core@0.6.9@webpack-core\lib\NormalModuleMixin.js:275:25)
at C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_webpack-core@0.6.9@webpack-core\lib\NormalModuleMixin.js:259:5
at Storage.finished (C:\Users\Administrator\AppData\Roaming\npm\node_modules\webpack\node_modules\_enhanced-resolve@0.9.1@enhanced-resolve\lib\CachedInputFileSystem.js:38:16)

@ ./~/_mime@1.3.6@mime/mime.js 87:12-35

分享到
取消 提交回答
全部回答(1)
  • x-cold
    2019-07-17 21:14:37

    npm i --save ali-oss
    确保安装成功了,然后在js里面require进来。如果还是报错,就检查一下node的版本

    0 0