开发者社区> 问答> 正文

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

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

展开
收起
song007 2017-06-01 10:43:29 10165 0
2 条回答
写回答
取消 提交回答
  • 啥项目啊,直接import不可以吗

    2020-11-21 10:07:06
    赞同 展开评论 打赏
  • 前端开发工程师,熟悉 node.js,半个运维。有时率性有时内敛,喜欢创造与分享,背包里有一堆有意思的玩意:大疆无人机、树莓派、Gokit等欢迎交流;

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

    2019-07-17 21:14:37
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
云存储之OSS实战进阶分享 立即下载
OSS运维基础实战手册 立即下载
一个跨平台的云服务SDK需要什么 立即下载