- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在 gruntfile.js 中设置 node_modules 目录的路径。我希望为我的所有 grunt 项目建立一个中央 node_module 目录。
是否可以设置外部node_module目录的路径?
当前设置(有效)
projekt1--gruntfile.js--package.json--node_modulesprojekt2--gruntfile.js--package.json--node_modules
设置我想要的
node_modulesproject1--gruntfile.js--package.jsonproject2--gruntfile.js--package.json
最佳答案
你可以......我一直在使用这个设置,没有任何问题。在您的每个项目 Gruntfile.js
文件中,只需将基础设置为一个目录,如下所示:
给定这样的文件夹结构:
node_modules
project1
app.js
Gruntfile.js
package.json
您的 Gruntfile.js
可能看起来像这样
module.exports = function(grunt) {
// Tell grunt where to find node_modules
// This is the line you're looking for
grunt.file.setBase('../');
// Your normal grunt config
grunt.initConfig({
// Your package.json file is now relative to the parent folder
pkg: grunt.file.readJSON('project1/package.json'),
// I use webpack, your tasks will probably be different
webpack: {
options: {},
build: {
// Paths are now resolved from the upper folder
// since we set the base path to one level up
entry: './project1/app.js',
output: {
// Again, the path must be relative to the parent folder
path: 'project1',
filename: 'app.min.js'
}
}
}
// etc...
});
// Load tasks...
}
setBase('../')
后,您需要确保所有文件路径均已正确解析,因为您的基本路径已更改为上一级。
警告...如果您发布或分发您的包,Grunt 任务将不适用于那些下载它的人,因为他们很可能不会与 node_modules 1 级别相同的设置。即使他们这样做,他们也可能不会将 project1
文件夹命名为相同的
关于javascript - 在 gruntfile.js 中设置 node_modules 的目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40867604/
我已经创建了自己的 npm 包,我们称它为 XYZ,它在 package.json 文件中具有 @material-ui 依赖项。 当我在项目 A 中安装它时,我在 XYZ 文件夹中嵌套了 node_
我遇到过这样一种情况:node_modules/@types 中的类型定义正在安装它自己的@types 依赖项,而这些“嵌套”@types 与我的顶级@types 冲突。 @types |-angul
当我 npm start 时出现此错误我的 react 项目。谁能解决这个问题? ./src/index.scss (./node_modules/css-loader/dist/cjs.js??re
我正在尝试使用 CopyWebpackPlugin 将一些文件从我的 node_modules 文件夹复制到我的构建文件夹中。 new CopyWebpackPlugin([ { from: 'n
我正在尝试使用 CopyWebpackPlugin 将一些文件从我的 node_modules 文件夹复制到我的构建文件夹中。 new CopyWebpackPlugin([ { from: 'n
我正在将一个项目从使用 Grunt 迁移到使用 Webpack。这个项目使用 jQuery。我注意到捆绑代码工作正常,即使我还没有将 jQuery 添加到 package.json,这看起来很奇怪。
当我在本地安装时,将我的模块两个父项放在我的项目文件夹之上。为什么会这样? 谢谢! 最佳答案 手动将 node_modules 文件夹扔进去就可以了 关于javascript - npm 在../..
我遇到了这个问题..有人有想法..那是什么意思.?想在我的本地机器上启动我的应用程序。但医生的工作方式。我在这里用模块或注释和 bcrypt 卡住?有人有解决这个问题的想法吗?为什么会出现这个问题。?
我最近发现了 ack 和 ack -ir --ignore-dir={node_modules,dist,.git} 对大多数事情都很好,但是这个 ---node_modules/ ---------
我在部署 netlify 时遇到问题,有些冲突我不明白。我尝试清除缓存、重建基础、重建包、在 netlify 上重新部署、重新安装 mini-CSS-extract-plugin。 调试 Netlif
我是 NodeJS 的新手,想使用 Sequelize。 我在新的 CentOS7 虚拟机上安装了 PostgreSQL 和 Node。 node -v v10.14.1 npm -v v6.5.0
我安装了 npm,当我第一次执行 sudo npm install some-package -g 时,它按照我的预期将该包安装到/usr/lib/node_modules,但随后它还在~/.npm。
我刚刚创建了一个带有“验证器”依赖项的 Node 模块。但是当我从 npm 安装它时,它不会在它自己的 node_module 目录中安装“验证器”模块。我不明白为什么,但这是我第一次创建自己的 No
我正在尝试使用 npm install packagename 将软件包安装到项目中.然后安装继续安装到 /home/myusername/node_modules/packagename/node_
我正在尝试构建我的 angular 项目并出现以下错误: Build Command: node --max_old_space_size=8192 node_modules/@angular/cli
我正在通过自制软件安装星舰,但出现此错误: Permission denied @ apply2files - /usr/local/lib/node_modules/expo-cli/node_mo
我试图在 Windows 10 中运行一个 Angular 项目。这与我在 Ubuntu 中执行的项目相同。当我克隆存储库并安装所有 Node 包时,我遇到了这个错误。 ERROR in./node_
我跑npm init npm i -D jest像这样 tutorial 运行推荐 nmp test 后出现此错误 这不是生物.js 或生物.test.js 的错误,因为没有发生此文件错误。我怎样才能
我刚刚将 npm 更新到 5.4.0。 现在,每当我想安装 npm 包时,我都会收到以下错误: D:\Sources\DownloadCms\Md.Download\Web.Angular>npm i
我正在尝试使用 npm 命令安装 appium。 每次尝试我都会遇到错误。 在最后一次尝试中,我引用了以下链接: node-gyp build error windows x64 为了在我的 Wind
我是一名优秀的程序员,十分优秀!