我想将我的Node模块存储在一个集中的位置,比如说,/var/http/common/让我的应用程序在不同的位置实时/运行/var/http/www/apps/APP#1_NAME/.
我能够设置server.js使用相对路径的需求require('../../../common/express'),但是从NPM的作者阅读帖子,听起来我正在攻击它,我应该用它npm link为Node创建一个"本地"引用(符号链接到真正的安装).
我首先安装了我的节点模块/var/http/common/,但是当我尝试创建symlink(npm link ../../../common/node_modules/express)时,npm似乎将其视为"全局"安装,并重新安装了express /usr/local/lib/node_modules/express(并创建了一个"本地"符号链接./node_modules/express ->)这不是我预期会发生的事情.这是我真正想要的吗?我应该先使用npm config set prefix吗?
我已经按照这个链接" https://github.com/ajaxorg/cloud9#installation-on-windows-experimental "在windows上安装cloud9但是我在"node server.js [args]"上发现了错误.准确到达错误是找不到模块.任何人都可以帮我解决这个问题.
谢谢Pradeep
我有一个问题,当我运行时git stash -u(即存储所有文件,包括未跟踪的文件),Git删除我的node_modules目录.除此之外,它甚至没有恢复它git stash pop- 我必须npm install再次运行才能恢复它.
在.gitignore(通过该行node_modules/*)中忽略node_modules ,并且据我所知,从未在项目的历史中提交(不git log --all -- node_modules返回任何内容).不应该git stash忽略它(即使提交未跟踪的文件)?我很确定我之前使用过git stash这样的节点而没有任何与node_modules有关的问题.
更新:我已经检查过,这个问题不仅限于某个特定项目 - 它似乎发生在我运行的任何地方git stash -u.值得一提的是,我的Git版本是2.6.3.windows.1(在Windows上).
努力将Angular(v4)添加到现有的ASP.NET MVC 4应用程序中.其中一个项目包括Selenium Web Driver,其中包含一个web.config文件.
node_modules\selenium-webdriver\lib\test\data\web.config
Run Code Online (Sandbox Code Playgroud)
此文件夹不包含在项目中,但位于我的Web应用程序文件夹中
myapplication\node_modules
myapplication\Controllers
myapplication\Views
myapplication\web.config
etc...
Run Code Online (Sandbox Code Playgroud)
selenium-webdriver文件夹中的web.config导致构建中断,并出现以下错误:
使用注册为的部分是错误的
allowDefinition ='MachineToApplication'超出应用程序级别.此错误可能是由于未在IIS中将虚拟目录配置为应用程序引起的.
非常常见的错误,当它是你自己的错误时很容易修复,但由于这是一个我正在使用的库,我无法控制文件.基于我的研究,我的问题有点扁平化:
我正在尝试编写一个节点模块,以便清理我的代码并将其分成不同的文件.
考虑以下代码:
module.exports = {
Hello : function(request, reply) {
return reply("Hello " + World());
},
World : function() {
return "World";
}
}
Run Code Online (Sandbox Code Playgroud)
如果我导入上面的模块并使用Hello函数作为特定路由的处理程序,我会收到HTTP 500内部服务器错误.
如果我将Hello函数更改为,我已将问题缩小到对World()的调用
Hello : function(request, reply) {
return reply("Hello World");
}
Run Code Online (Sandbox Code Playgroud)
然后它工作正常,所以它似乎在从导出对象中调用另一个函数时被绊倒
有谁知道为什么会这样,以及如何解决它?
我看过一些stackoverflow帖子和github问题,但是找不到对我有用的东西。
我有一种自定义字体,用于通过npm安装的图标。这些是我的文件夹a-icons中的文件node_modules:
a-icon.css
a-icon.eot,
a-icon.ttf,
a-icon.woff,
a-icon.svg
Run Code Online (Sandbox Code Playgroud)
在我的主要样式表中,我添加了:
@import '~a-icons/a-icon';
@font-face {
font-family: 'a-icon';
src: url('../../../node_modules/a-icons/a-icon.eot');
src:
url('../../../node_modules/a-icons/a-icon.ttf') format('truetype'),
url('../../../node_modules/a-icons/a-icon.woff') format('woff'),
url('../../../node_modules/a-icons/a-icon.svg') format('svg');
}
Run Code Online (Sandbox Code Playgroud)
@import '~a-icons/a-icon' 具体是给我一个错误,说它找不到.eot,.ttf,.woff,.svg
这是错误之一:
ERROR in ./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_modules/postcss-loader/lib?{"ident":"postcss","sourceMap":false}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":false,"precision":8,"includePaths":[]}!./src/assets/stylesheets/global-styles.scss
Module not found: Error: Can't resolve './a-icon.eot' in '/Users/rmadan/a-one/a-platform/src/assets/stylesheets'
resolve './a-icon.eot' in '/Users/rmadan/a-one/a-platform/src/assets/stylesheets'
using description file: /Users/rmadan/a-one/a-platform/package.json (relative path: ./src/assets/stylesheets)
Field 'browser' doesn't contain a valid alias configuration
after using description file: /Users/rmadan/a-one/a-platform/package.json (relative path: ./src/assets/stylesheets)
using description file: /Users/rmadan/a-one/a-platform/package.json (relative path: ./src/assets/stylesheets/a-icon.eot)
no extension …Run Code Online (Sandbox Code Playgroud) 以下是我的包json文件.我已经成功安装了node_modules.但得到错误:
"TypeError:无法读取未定义的属性'babel'"
在运行"webpack --watch"时.如果有人知道这一点,请告诉我.
"axios": "0.16.2",
"babel-plugin-root-import": "^5.1.0",
"bootstrap": "3.3.7",
"chalk": "^2.3.0",
"chart.js": "^2.7.1",
"del": "^3.0.0",
"html-entities": "^1.2.1",
"jquery": "3.1.1",
"karma-es6-shim": "^1.0.0",
"leaflet": "1.0.*",
"less": "2.7.2",
"libphonenumber-js": "^1.2.12",
"lodash": "4.17.4",
"moment": "^2.19.1",
"store": "^2.0.12",
"url-loader": "0.5.8",
"vee-validate": "2.0.0-rc.7",
"vue": "2.4.2",
"vue-chartjs": "^2.7.2",
"vue-loader": "12.0.3",
"vue-paginate": "3.4.0",
"vue-resource": "1.2.1",
"vue-router": "2.3.1",
"vue-template-compiler": "2.4.2",
"vuejs-datepicker": "0.6.3",
"vuex": "^2.5.0"
},
"devDependencies": {
"babel-cli": "6.23.0",
"babel-core": "6.23.1",
"babel-loader": "6.3.2",
"babel-preset-es2015": "6.22.0",
Run Code Online (Sandbox Code Playgroud) 我有一个使用bcrypt库的节点项目。当我将其部署到Azure时(在我的本地计算机上运行良好,并且我的计算机和Azure服务器都在运行Node 10.7.0),对于每个请求,我都会收到HTTP错误500。当我检查应用程序日志以了解问题所在时,这是我收到的完整错误消息(减去堆栈跟踪):
Application has thrown an uncaught exception and is terminated:
Error: The module '\\?\D:\home\site\wwwroot\node_modules\bcrypt\lib\binding\bcrypt_lib.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
Run Code Online (Sandbox Code Playgroud)
我尝试了以下操作,但均未成功:
npm rebuild在Kudu调试控制台上运行node_modules从我的.gitignore中省略,并将机器的节点模块目录直接推到azure(是的,我很拼命)我该如何解决?
在由生成的文件夹中ng build simple-lib,我看到的结构比其他节点模块更复杂。我看到的是bundles,,esm2015和esm5,而不是index.js导出和导入其他成员public_api.d.ts。
我在esm5和esm2015文件夹中都看到了simple-lib的编译版本。我想知道如何使用esm .js文件以及何时使用esm2015代替esm5。据我了解,esm2015允许使用较小的捆绑包和摇树,但我不确定何时选择使用哪个模块。我希望生成一个可以在节点项目中使用的库,并且希望能帮助您理解是否以及如何实现。谢谢。
$ tree simple-lib/
simple-lib/
??? bundles
? ??? simple-lib.umd.js
? ??? simple-lib.umd.js.map
? ??? simple-lib.umd.min.js
? ??? simple-lib.umd.min.js.map
??? esm2015
? ??? lib
? ? ??? simple-lib.component.js
? ? ??? simple-lib.module.js
? ? ??? simple-lib.service.js
? ??? public_api.js
? ??? simple-lib.js
??? esm5
? ??? lib
? ? ??? simple-lib.component.js
? ? ??? simple-lib.module.js
? ? ??? simple-lib.service.js
? ??? public_api.js
? ??? simple-lib.js
??? …Run Code Online (Sandbox Code Playgroud) 我有一个npm包,其结构如下:
./
./backend
./package.json
package.json
Run Code Online (Sandbox Code Playgroud)
所以基本上两个npm模块在同一个文件夹中,一个是另一个的子文件,文件结构明智.
我安装的方式是,我将一个安装后的脚本放在父package.json中:
"postinstall": "cd backend && npm install && cd .."
Run Code Online (Sandbox Code Playgroud)
如果我全局安装它会发生什么:它首先打印一些警告,基本上没有安装包.像这样:
npm WARN enoent ENOENT: no such file or directory, open '/usr/lib/node_modules/inschpektor/backend/node_modules/trim-newlines/package.json'
Run Code Online (Sandbox Code Playgroud)
那些出现在所有依赖关系中./backend/package.json.
我已经使用--unsafe-perm标志运行安装:
npm install -g inschpektor --unsafe-perm 它安装包含postinstall脚本的父package.json.
我得到的最终日志错误消息是这一个:
npm ERR! path /usr/lib/node_modules/inschpektor/backend/node_modules/ansi-regex/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/usr/lib/node_modules/inschpektor/backend/node_modules/ansi-regex/package.json'
npm ERR! enoent This is related to npm not being able to …Run Code Online (Sandbox Code Playgroud) node-modules ×10
node.js ×5
npm ×4
angular ×2
angular-cli ×2
javascript ×2
angularjs ×1
azure ×1
babel ×1
backend ×1
cloud9-ide ×1
css ×1
debian ×1
fonts ×1
git ×1
git-stash ×1
gitignore ×1
module ×1
npm-install ×1
npm-scripts ×1
typescript ×1
vue.js ×1
webpack ×1