Answer the question
In order to leave comments, you need to log in
How to include nodejs package in yii2 project?
In a Yii2 project, you need to include a dependency on the nodejs package - https://github.com/tmpvar/2d-polygon-boolean
In composer.json I write:
{
//...
"require": {
"npm-asset/2d-polygon-boolean" : ">=1.0.1"
}
//...
}
composer update
in the folder ./vendor/npm
along with the specified (2d-polygon-boolean) class PolygonBooleanAsset extends yii\web\AssetBundle {
public $sourcePath = '@npm/2d-polygon-boolean';
public $js = [
'2d-polygon-boolean.js'
];
}
Uncaught ReferenceError: require is not defined
Answer the question
In order to leave comments, you need to log in
npm-asset assets are not suitable as normal JS for the browser this is all for server-side nodejs
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question