未找到本地吞吐(尝试运行: npm install gup)

我创建了一个模块(webapp-module-storage) ,其定义如下:

包裹 Json

{
"dependencies": {
...
},
"devDependencies": {
"gulp": "^3.9.1",
...
},
"name": "webapp-module-storage",
"scripts": {
"postinstall": "gulp build",
"test": "gulp test"
}
}

我认为我可以使用我的模块内的另一个模块时,安装它与:

  • npm install github:myorg/webapp-module-storage#master

然而,当我安装我的模块时,我得到了这个错误:

未发现局部吞咽

尝试运行: npm install gup

截图

enter image description here

我的理解是,gulp与我的模块一起发布,因为我在 devDependencies中声明了它,但是看起来我的 npm postinstall脚本找不到 gulp

我错过了什么吗?

123343 次浏览

Try installing your dependencies first:

npm install

If still does not work, install gulp globally:

npm install -g gulp

if you find problems installing it. type sudo before npm.

In case you need more info about why you need gulp globally and locally read this answer

Try running npm link gulp in your application directory (to create a local link to the globally installed Gulp module).

I have tried all the solutions mentioned. At the end I was able to solve the problem by realising that the gulpfile.js file was missing on the location i was using the gulp. After placing the gulpfile.js in the folder from where I was executing gulp, it worked for me.

npm link gulp --no-bin-links
Run this

where npm link gulp creates a local link to globally installed gulp module and --no-bin-links argument will prevent npm from creating symlinks for any binaries the package might contain.

You can't translate symlinks to a synchronized folder on Windows share, so you will need '--no-bin-links' to go around it.

Use it for any filesystem that doesn’t support symbolic links.

Symlinks, or symbolic links, are “virtual” files or folders which reference a physical file or folder located elsewhere, and are an important feature built in to many operating systems, including Linux and Windows.

npm link gulp --force

Using this command worked well for me.

Put Gulp into the regular dependencies of the project:

npm i gulp

And then have your scripts section reference the local Gulp like that:

  "scripts": {
"postinstall": "./node_modules/.bin/gulp build",
"test": "./node_modules/.bin/gulp test"
}

I used Visual Studio Code and Terminal with Power Shell and have this problem either. This problem for me disappeared when I changed Execution Policy. I get info about this solution from gulp. Execution Policy changin example is in the picture.Set Execution Policy