Use of @ symbol in Node module names(在 Node 模块名称中使用 @ 符号)
问题描述
I'm looking at some code from a coworker wrote and she's using the @
symbol in require statements. This is the first line of one of these files:
var restServer = require('@company/config')
When I try to run this code, I get an error:
Error: Cannot find module '@company/config'
Which I frankly expect, there's nothing that looks like this in my directory for require to recognize! It seems like there's some magic going on here, which I hate.
All I can guess is that either this is some obscure npm or Node trick that I haven't been exposed to, or maybe that there's some other dark art of configuration that I'm not getting. Any info appreciated, even if it's just an explanation of how @
works with require.
Other ideas: Chef is involved somewhere in this whole thing, so that might be relevant.
Update: 99% certain this is an issue with the way npm config
works at this point, but still unsure of how to go about fixing it.
Update2 based on some stuff I uncovered:
Dereks-MacBook-Pro:project-dir derekjanni$ npm config set //registry.npmjs.org/:authtoken $SECRET_TOKEN
Dereks-MacBook-Pro:project-dir derekjanni$ npm install
npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/Cellar/node/5.5.0/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v5.5.0
npm ERR! npm v3.5.3
npm ERR! code E404
npm ERR! 404 Not found : @company/config
npm ERR! 404 '@company/config' is not in the npm registry.
So I solved this one myself.
Turns out @company/config
is one of our private NPM repositories, hosted on npm and defined by this alias to an internal GitHub repository: it had nothing to do with how require
works.
Using @
may or may not be a protocol that I was unaware of for private NPM repos, keep that in mind if you run into this.
这篇关于在 Node 模块名称中使用 @ 符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Node 模块名称中使用 @ 符号
基础教程推荐
- 响应更改 div 大小保持纵横比 2022-01-01
- 悬停时滑动输入并停留几秒钟 2022-01-01
- 有没有办法使用OpenLayers更改OpenStreetMap中某些要素 2022-09-06
- 动态更新多个选择框 2022-01-01
- 当用户滚动离开时如何暂停 youtube 嵌入 2022-01-01
- 在for循环中使用setTimeout 2022-01-01
- 角度Apollo设置WatchQuery结果为可用变量 2022-01-01
- 在 JS 中获取客户端时区(不是 GMT 偏移量) 2022-01-01
- 我什么时候应该在导入时使用方括号 2022-01-01
- Karma-Jasmine:如何正确监视 Modal? 2022-01-01