Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
安装包后运行npm脚本_Npm_Webpack - Fatal编程技术网

安装包后运行npm脚本

安装包后运行npm脚本,npm,webpack,Npm,Webpack,我有一个简单的git存储库 我想将其用作npm依赖项,但不在npm中发布 换句话说,我想在我的另一个存储库中作为依赖项安装这个包 npmi——保存git+https://github.com/alexey-sh/test_webpack_with_npm.git 但我想在我的测试网页包中使用一个现代的js,并在包安装过程后将其编译成旧的javascript。为了实现它,我创建了npm脚本(使用npm包测试网页) 所以现在有一件奇怪的事: 如果我运行npm运行build从test\uwebpack

我有一个简单的git存储库

我想将其用作npm依赖项,但不在npm中发布

换句话说,我想在我的另一个存储库中作为依赖项安装这个包

npmi——保存git+https://github.com/alexey-sh/test_webpack_with_npm.git

但我想在我的
测试网页包中使用一个现代的js,并在包安装过程后将其编译成旧的javascript。为了实现它,我创建了npm脚本(使用npm包测试网页)

所以现在有一件奇怪的事: 如果我运行
npm运行build
test\uwebpack\unpm
存储库,我可以得到
dist/index.js
而无需
class
声明(如我所料)。 但是如果我通过以下命令安装包
npmi——保存git+https://github.com/alexey-sh/test_webpack_with_npm.git
我得到了另一种类型的
dist/index.js
,还有
class
声明

如何使用npm正确安装
test\u网页?我想用npm/dist/index.js在
node\u modules/test\u webpack\u中看到旧的js

复制步骤:

  • mkdir我的测试项目
  • cd我的测试项目
  • npm init
  • npmi——保存git+https://github.com/alexey-sh/test_webpack_with_npm.git
  • 用npm/dist/index.js检查节点模块/测试网页

谢谢

修复非常简单。只需在网页包配置中将排除替换为包含即可

include:path.join('sources'),

那很好用

更新的配置在这里

  "scripts": {
    "install": "npm run build",
    "build": "webpack --mode production --config webpack.config.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },