npm作业和命令行之间的区别

时间:2018-09-27 12:34:50

标签: javascript node.js npm webpack npm-scripts

我已经为我的网络扩展设置了webpack。 在package.json中,我定义了以下脚本:

"scripts": {
  "start": "webpack --config webpack.config.js"
},

因此,可以使用以下两个选项之一启动webpack:

  • npm运行开始
  • webpack --config webpack.config.js

但是尽管npm run start工作正常,但直接调用webpack --config webpack.config.js失败。 这是我的代码:https://github.com/lhk/webextensions-webpack-boilerplate

您可以按照以下步骤重现该问题:

git clone https://github.com/lhk/webextensions-webpack-boilerplate
cd webextensions-webpack-boilerplate
npm install
tsc -p tsconfig.json
webpack --config webpack.config.js

错误消息是:

clean-webpack-plugin: /home/lhk/.local/share/Trash/files/temp.2/webextensions-webpack-boilerplate/dist has been removed.
(node:21823) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
/usr/lib/node_modules/webpack/lib/Chunk.js:827
        throw new Error(
        ^

Error: Chunk.entrypoints: Use Chunks.groupsIterable and filter by instanceof Entrypoint instead
    at Chunk.get (/usr/lib/node_modules/webpack/lib/Chunk.js:827:9)
    at /home/lhk/.local/share/Trash/files/temp.2/webextensions-webpack-boilerplate/node_modules/extract-text-webpack-plugin/dist/index.js:176:48
    at Array.forEach (<anonymous>)
    at /home/lhk/.local/share/Trash/files/temp.2/webextensions-webpack-boilerplate/node_modules/extract-text-webpack-plugin/dist/index.js:171:18
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/usr/lib/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:7:1)
    at AsyncSeriesHook.lazyCompileHook (/usr/lib/node_modules/webpack/node_modules/tapable/lib/Hook.js:154:20)
    at Compilation.seal (/usr/lib/node_modules/webpack/lib/Compilation.js:1215:27)
    at hooks.make.callAsync.err (/usr/lib/node_modules/webpack/lib/Compiler.js:541:17)
    at _err0 (eval at create (/usr/lib/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:11:1)
    at _addModuleChain (/usr/lib/node_modules/webpack/lib/Compilation.js:1066:12)
    at processModuleDependencies.err (/usr/lib/node_modules/webpack/lib/Compilation.js:982:9)
    at _combinedTickCallback (internal/process/next_tick.js:132:7)
    at process._tickCallback (internal/process/next_tick.js:181:9)

系统信息:

  • 节点版本为:v8.12.0
  • npm版本为:6.4.1
  • 操作系统是:ubuntu 18.04(64位)

0 个答案:

没有答案