开发者社区> 问答> 正文

学习webpack时使用npm run 命令出错,直接webpack就可以打包? 400 报错

学习webpack时使用npm run 命令出错,直接webpack就可以打包? 400 报错

{ "name": "webpack_test02", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo "Error : no test specified"&& exit 1", "webpack": "webpack " },

配置里就是这么写的,在命令行直接使用webpack就可以顺利打包,使用npm run webpack提示错误,如下

Error: Cannot find module 'os-browserify/browser.script'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.resolve (internal/module.js:27:19)
    at Object.<anonymous> (D:\app\webpack_test02\node_modules\node-libs-browser\index.js:17:28)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (D:\app\webpack_test02\node_modules\webpack\lib\node\NodeSourcePlugin.js:7:23)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at WebpackOptionsApply.process (D:\app\webpack_test02\node_modules\webpack\lib\WebpackOptionsApply.js:71:25)
    at webpack (D:\app\webpack_test02\node_modules\webpack\lib\webpack.js:36:48)
    at processOptions (D:\app\webpack_test02\node_modules\webpack\bin\webpack.js:305:14)
    at Object.<anonymous> (D:\app\webpack_test02\node_modules\webpack\bin\webpack.js:363:1)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\node.js\\node.exe" "C:\\node.js\\node_modules\\npm\\bin\\npm-cli.js" "run" "webpack"
npm ERR! node v6.10.0
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! webpack_test02@1.0.0 webpack: `webpack `
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webpack_test02@1.0.0 webpack script 'webpack '.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the webpack_test02 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     webpack
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs webpack_test02
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls webpack_test02
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\app\webpack_test02\npm-debug.log

展开
收起
爱吃鱼的程序员 2020-06-02 17:09:04 776 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    楼主找到解决的方法了吗  我也碰到了。求指教

    2020-06-02 17:09:23
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
基于webpack和npm的前端组件化实践 立即下载
基于FAAS构建NPM同步CDN 立即下载
从Web到Cloud App 立即下载

相关镜像