我创建了一个插件网站。每个插件都遵循一定的名称标准和合同。在我的 main.js 中,我按照名称标准“动态”加载所有包:
const context = require.context("../../node_modules", true, /plugin\-\w+\/dist\/(index\.js|styles\.css)$/)
Run Code Online (Sandbox Code Playgroud)
这需要整个 node_modules 文件夹的上下文并加载所有名为“plugin-X”的模块。它从这些模块中查找“dist/index.js”和“dist/styles.css”。那些后来被导入:
context.keys().forEach(path => {/* do stuff */ })
Run Code Online (Sandbox Code Playgroud)
只要使用 npm install path/to/tgz 安装软件包,这就会非常有效。然而,这并没有带来愉快的开发体验。因此,在我的 plugin-X 文件夹中,我使用“npm link”,而在我的网站中,我使用“npm link plugin-X”。
当我现在启动 webpack 时,整个事情在创建 15K 文件句柄后爆炸。如果我删除“plugin-X”中的 node_modules 文件夹,它就可以工作。但是,我需要 node_modules 来使用 babel 和其他东西进行构建,以识别 src 文件夹中的更改以重建并将新脚本放入 dist 文件夹中。
有什么办法可以做到这一点吗?或者也许我在研究如何做到这一点时错过了另一个选择?
问候
我一直在尝试按照此处的 npm pythonshell 文档进行操作。我只是想找一个简单的例子来正确运行但没有成功,网上的例子不多,但我确实尝试在 stackoverflow 上遵循这个例子。那么我的代码到底有什么问题呢?我不确定为什么会收到以下错误。我在 python 中更自在,nodejs 对我来说是一个新领域。感谢您的任何帮助。
test.py 代码:
print("This is a test")
Run Code Online (Sandbox Code Playgroud)
带有pythonshell测试的Nodejs:
var PythonShell = require('python-shell');
var options = {
mode: 'text',
pythonPath: '/bin/bash/python2',
pythonOptions: ['-u'],
scriptPath: './TestProject/',
args: ['value1', 'value2', 'value3']
};
PythonShell.run('test.py', options, function (err, results) {
if (err) throw err;
// results is an array consisting of messages collected during execution
console.log('results: %j', results);
});
Run Code Online (Sandbox Code Playgroud)
这是我的错误
internal/child_process.js:313
throw errnoException(err, 'spawn');
^
Error: spawn ENOTDIR
at exports._errnoException (util.js:1022:11)
at ChildProcess.spawn …Run Code Online (Sandbox Code Playgroud) 我想组织我的项目以轻松重用某些模块。我不确定我的方法是否正确。
假设我们有一个带有两个子项目的主项目。像这样的东西:
- main-project
- index.js
- project.json
- node_modules
- reused_module
...
- sub-project1
- index.js
- project.json
- node_modules
- private_module1
...
- sub-project2
- index.js
- project.json
- node_modules
- private_module2
...
Run Code Online (Sandbox Code Playgroud)
现在,project2 inner1 和inner2 都可以访问reused_module,但我想知道它们project.json 文件中的依赖关系。
如果reused_module 列在inner1/package.json 的依赖部分中,它将被复制到它自己的node_modules(我想避免,以强制重用)。
如果reused_module 未在inner1/package.json 中列出,则此依赖项将是“隐藏的”。
我现在应该对此有什么看法吗?难道我做错了什么?
我正在尝试构建一个 node.js C++ 使用,node-gyp但无法弄清楚如何指定,-Wl,-rpath,$ORIGIN以便从 node 加载时它可以找到与addon.node.
我试过这样设置我的binding.gyp:
"libraries": [
"-L../../install_release_x64/",
"-llibppp"
],
"ldflags": [
"-Wl,-rpath,'$ORIGIN'"
],
"cflags_cc": [
"-fexceptions",
"-fPIC",
"-Wno-unknown-pragmas"
]
Run Code Online (Sandbox Code Playgroud)
但是当我运行时$ readelf -d addon.node,结果是这样的:
Dynamic section at offset 0x7d10 contains 29 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [liblibppp.so]
0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000e (SONAME) Library soname: [addon.node]
0x000000000000000f (RPATH) Library rpath: [RIGIN]
0x000000000000000c (INIT) 0x37a0 …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Visual Studio 作为我的 IDE,以使用 Angular 2 开发 ASP.NET MVC 5 SPA。当我尝试构建项目时,问题就出现了。它在*.d.ts文件中给了我很多错误。
我使用angular-cli以下命令创建了项目:ng new project-name
这是解决方案资源管理器的样子:
我如何摆脱这些错误?我在 Visual Studio Code 中使用 angular 2 没有任何问题
更新 :
根据您的回答,我在tsconfig.json文件中添加了以下内容,但似乎不起作用
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2016"
]
},
"exclude": [
"./node_modules",
"**/*.spec.ts"
]
}
Run Code Online (Sandbox Code Playgroud) node-modules single-page-application asp.net-mvc-5 visual-studio-2015 angular
我正在尝试使用我创建的 nodejs 包,有人可以指出我做错了什么。
这是包结构的样子:
node_modules
|__my_commons
| |__dist
| |__src
| | |__helpers.d.ts
| | |__helpers.js
| | |__index.d.ts
| | |__index.js
| |__node_modules <=This got recursively installed
| |__.npmignore
| |__package.json
src
|_app/app.component.ts <= Here I am using it
Run Code Online (Sandbox Code Playgroud)
my_commons/package.json
{
"_args": [
[
{
"raw": "my_commons@bitbucket:ishan_dutta/my_commons",
"scope": null,
"escapedName": "my_commons",
"name": "my_commons",
"rawSpec": "bitbucket:ishan_dutta/my_commons",
"spec": "bitbucket:ishan_dutta/my_commons",
"type": "hosted",
"hosted": {
"type": "bitbucket",
"ssh": "git@bitbucket.org:ishan_dutta/my_commons.git",
"sshUrl": "git+ssh://git@bitbucket.org/ishan_dutta/my_commons.git",
"httpsUrl": "git+https://bitbucket.org/ishan_dutta/my_commons.git",
"shortcut": "bitbucket:ishan_dutta/my_commons",
"directUrl": "https://bitbucket.org/ishan_dutta/my_commons/raw/master/package.json"
}
},
"/Users/ishandutta2007/Documents/Projects/my_proj"
]
],
"_from": …Run Code Online (Sandbox Code Playgroud) 我在Github pages上托管一个站点,并使用 Jekyll 生成它。
我加角和Lodash到我的项目中使用npm,但不希望200个多文件上传至GitHub的,所以我说node_modules我的.gitignore文件,只是确保他们加入作为内的相关性package.json。然后问题就变成了 GitHub pages/Jekyll 在 (Jekyll) 生成时不会自动安装包。
所以我的问题是,如何在 GitHub 页面上使用 NPM 而无需实际将我的 node_modules 文件夹上传到我的 GitHub 存储库?
我是 docker 的初学者,试图使用 Creator 的更新 bash 子系统让它在我的 Windows 10 机器上运行。我的 dockerfile 在我的 mac 上构建得很好,但是当我docker build在 Windows 上尝试使用相同的文件时,我收到如下错误:
time="2017-08-28T14:44:36-07:00" level=error
msg="Can't add file \\\\?\\C:\\Users\\username\\Workspace\\...\\node_modules\\.bin\\nodemon
to tar: readlink \\\\?\\C:\\Users\\username\\Workspace\\...\\node_modules\\.bin\\nodemon:
The system cannot find the file specified."
Run Code Online (Sandbox Code Playgroud)
这是为我所有的 node_modules 依赖项打印出来的。我的第一个问题是:是什么触发了我所有 node_modules 的“添加”操作?这些错误信息是在我的 dockerfile 的第一行执行之前打印出来的
Step 1/25 : FROM ubuntu:14.04
Run Code Online (Sandbox Code Playgroud)
其次,这个问题是否与windows中的不同路径有关?对我来说,错误最奇怪的部分是奇怪的路径\\\\?\\C:\\Users\\username。路径中有过多的斜杠和问号是怎么回事?
第三,就我一个人吗?还是大家在windows bash子系统上使用docker时遇到问题?
注意:我已经尝试设置 Docker 工具箱并运行快速启动终端。运行快速启动终端时出现以下错误
Error with pre-create check:
"This computer is running Hyper-V. VirtualBox won't boot a 64bits VM when Hyper-V is activated. …Run Code Online (Sandbox Code Playgroud) 我正在尝试更新 node_modules 文件夹中的 html,但当我更改时,它不会更新。是否无法更新 node_modules 中的文件?
我有一个导入弹出模块的项目
import {PopupModule} from 'ng2-opd-popup';
Run Code Online (Sandbox Code Playgroud)
我需要能够更改此文件夹路径中存在的代码(/node_modules/ng2-opd-popup/components/popup/popup.component.html)
div id="ng2-opd-popup-main" *ngIf="visible" [ngClass]="mainClass" [ngStyle]="mainStyle">
<div class="row">
<div style="display: inline-block;width:100%">
<div id="ng2-opd-popup-well" [ngStyle]="wellStyle" class="ng2-opd-popup-well ng2-opd-popup-well-sm">{{popupService.options.header}}</div>
</div>
<div style="margin:20px;">
<ng-content></ng-content>
<div *ngIf="popupService.options.showButtons" style="margin-bottom:20px;margin-top:20px;float: right">
<div *ngIf="popupService.options.showConfirm">
<button id="confirmBtn" [ngClass]="confirmBtnStyle" (click)="confirmYes()">{{popupService.options.confirmBtnContent}}</button>
</div>
<div *ngIf="popupService.options.showCancel">
<button id="cancelBtn" [ngClass]="cancelBtnStyle" type="reset" (click)="confirmNo()">{{popupService.options.cancelBtnContent}}</button>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
假设我想完全取出取消按钮。当我更改它并从我的项目中保存它时,即使 html 已更改,它也不会更新。
我正在尝试使用第三方模块,该模块可用作我的 angular 应用程序中的节点模块。我刚刚开始使用 angular,我还没有完全理解模块化行为。我正在通过脚本标签导入角度模块(路由器等)并将它们注入我的主应用程序模块,但我不知道如何注入节点模块。
谷歌让我对 CommonJS、AMD 等词更加困惑,因为我刚刚开始学习模块化方法。有人可以指导我如何在我的应用程序模块中注入节点模块吗?
我正在使用 AngularJS v1.6.4。我可以选择使用 browserify 和 webpack。他们两个我都有。
node-modules ×10
node.js ×4
angular ×2
angularjs ×2
npm ×2
webpack ×2
browserify ×1
docker ×1
gcc ×1
github ×1
github-pages ×1
javascript ×1
jekyll ×1
node-gyp ×1
package.json ×1
python ×1
require ×1
typescript ×1
windows ×1